#include #include #include class SinusStream : public CL_SoundProvider_Session { public: SinusStream() { pos = 0; playing = false; stream_length = 60*44100; // play sound for 60 seconds. } virtual bool eof() const { return (pos >= stream_length); // only stream for four seconds. } virtual void stop() { playing = false; } virtual bool play() { playing = true; return true; } virtual int get_position() const { return pos; } virtual bool set_position(int new_pos) { pos = new_pos; return true; } virtual int get_num_samples() const { return stream_length; } virtual int get_data(void **data_ptr, int samples_req) { if (samples_req + pos > stream_length) // playing beyond the end of stream data { samples_req = stream_length - pos; if (samples_req < 0) { stop(); return 0; } } short *channel1 = (short *) data_ptr[0]; // Generate required audio samples for (int i=0; i