started work on the CHIP-8 interpreter
This commit is contained in:
26
BuzzerSDL.hpp
Normal file
26
BuzzerSDL.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <SDL2/SDL_audio.h>
|
||||
|
||||
#include "Peripherals.hpp"
|
||||
|
||||
class BuzzerSDL : public chocochip8::Buzzer {
|
||||
public:
|
||||
using sample_t = Sint16;
|
||||
|
||||
BuzzerSDL(unsigned frequency);
|
||||
~BuzzerSDL();
|
||||
|
||||
void on() override;
|
||||
void off() override;
|
||||
|
||||
private:
|
||||
static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len);
|
||||
void copySamples(Uint8 *stream, int len);
|
||||
|
||||
private:
|
||||
std::vector<sample_t> mSamples;
|
||||
SDL_AudioDeviceID mAudioDevice;
|
||||
size_t miCurrentSample;
|
||||
};
|
||||
Reference in New Issue
Block a user