40 lines
642 B
C
40 lines
642 B
C
/*
|
|
// Created by bruno on 16.2.2025.
|
|
*/
|
|
|
|
#ifndef RISCB_AUDIO_H
|
|
#define RISCB_AUDIO_H
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define SAMPLE_RATE 44100
|
|
#define NUM_SYNTH_VOICES 3
|
|
|
|
typedef enum {
|
|
WAVE_SINE,
|
|
WAVE_SQUARE,
|
|
WAVE_SAWTOOTH,
|
|
WAVE_TRIANGLE,
|
|
WAVE_NOISE
|
|
} Waveform;
|
|
|
|
typedef struct {
|
|
uint8_t volume;
|
|
uint16_t frequency;
|
|
uint8_t phase;
|
|
Waveform waveform;
|
|
} SynthVoice;
|
|
|
|
typedef struct {
|
|
SynthVoice synthVoices[NUM_SYNTH_VOICES];
|
|
} AudioData;
|
|
|
|
extern AudioData audioData;
|
|
|
|
void audio_callback(void *userdata, Uint8 *stream, int len);
|
|
|
|
#endif //RISCB_AUDIO_H
|