More progress on audio and rendering
This commit is contained in:
17
util/audio.h
17
util/audio.h
@@ -9,9 +9,18 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../tiles/tile.h"
|
||||
|
||||
#define SAMPLE_RATE 44100
|
||||
#define NUM_SYNTH_VOICES 256
|
||||
#define SMOOTHING_FACTOR 0.001f
|
||||
|
||||
typedef struct {
|
||||
float timeSec; // When to trigger this event
|
||||
uint8_t type; // 0 = Note On, 1 = Note Off
|
||||
uint8_t note;
|
||||
uint8_t velocity;
|
||||
} MidiEvent;
|
||||
|
||||
typedef enum Waveform {
|
||||
WAVE_SINE,
|
||||
@@ -23,16 +32,18 @@ typedef enum Waveform {
|
||||
|
||||
typedef struct SynthVoice {
|
||||
Waveform waveform;
|
||||
uint8_t phase;
|
||||
double phase;
|
||||
uint16_t frequency;
|
||||
uint8_t volume;
|
||||
SDL_Rect sourceRect;
|
||||
MiniRect sourceRect;
|
||||
float smoothedAmp; // a float that holds the exponentially smoothed amplitude
|
||||
} SynthVoice;
|
||||
|
||||
typedef struct AudioData {
|
||||
SynthVoice synthVoices[NUM_SYNTH_VOICES];
|
||||
SDL_Rect *playerRect;
|
||||
float maxPanDistance;
|
||||
uint64_t totalSamples;
|
||||
} AudioData;
|
||||
|
||||
extern AudioData audioData;
|
||||
@@ -41,4 +52,6 @@ void audio_callback(void *userdata, Uint8 *stream, int len);
|
||||
|
||||
uint16_t getAvailableChannel();
|
||||
|
||||
void load_midi_file(const char *path);
|
||||
|
||||
#endif //RISCB_AUDIO_H
|
||||
|
Reference in New Issue
Block a user