Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <kit/audio.hpp>
- using namespace kit;
- #define FORMULA t*(42&t>>10) //the elusive 42 melody~
- #define TARGET_SAMPLE_RATE 8000
- u64 _t = KIT_U64_MAX;
- s32 audio_callback(const void* _input, void* _output,
- const AudioStreamInfo* info, void* userdata)
- {
- (void)_input;
- u8* output = (u8*)_output;
- u32 numSamples = info->sampleFrames;
- f64 sampleRate = info->sampleRate;
- f64 rateRatio = (f64)TARGET_SAMPLE_RATE/sampleRate;
- for(u32 i=0; i<numSamples; ++i){
- u64 t = (u64)((++_t)*rateRatio);
- output[i] = (u8)( FORMULA );
- }
- return ASTREAM_RTN_CONTINUE;
- }
- int main(int argc, char** argv){
- AudioStreamParams params;
- params.callback = audio_callback;
- params.outputDeviceID = audio::getDefOutputDevice();
- params.outputFormat = ASTREAM_FMT_U8;
- params.outputChannels = 1;
- AudioStream stream(¶ms);
- stream.start();
- time::sleep(8300); //plays 1 loop of 42 melody bytebeat
- stream.stop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement