This commit is contained in:
2025-04-23 22:55:22 +02:00
commit 8fd5f1cf1e
8 changed files with 565 additions and 0 deletions

39
util/audio.h Normal file
View File

@@ -0,0 +1,39 @@
/*
// 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