#pragma once #include #include "shatter.h" using namespace std; class AudioLoop { public: AudioLoop(FMOD::System* sound_sys); ~AudioLoop(); void add_samples(const double* samples, unsigned long n_samples); void add_sample(double sample); void stutter(); void scramble(); void glitch(); int load_file(const char* fname); void play(); void clear(); SAMPLE get_sample(int offset); // graphical representation of the loop around the current sample void render(); void set_3D(const STVector3 & pos, const STVector3 & vel); double _volume; vector _audio_vector; // makes it so that the pcmreadcallback forwards the data to the death_ball void set_death_handle(DeathBall* death_ball); static FMOD_RESULT pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen); static FMOD_RESULT pcmsetposcallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype); private: void do_stutter(unsigned long index1, unsigned long index2); void do_scramble(unsigned long index1, unsigned long index2); void do_glitch(unsigned long index1, unsigned long index2); SAMPLE get_next_sample(); void smooth_the_gap(); unsigned long _cur_sample; FMOD::Sound* _sound; FMOD::Channel* _channel; TickTimer* _tick_timer; DeathBall* _death_ball; };