void TogglePlaying () { if (ReachedEnd) SetSongPosition(0); ReachedEnd = false; SongPlaying = !SongPlaying; PlayToggleButton->texref = slLoadTexture(SongPlaying ? PAUSE_BUTTON_IMGPATH : PLAY_BUTTON_IMGPATH); }
// Mixer Controller void Mix (float* buf, slBU samples, bool stereo, slScalar persample) { slBU cur; if (SongPlaying) { if (GetSongPosition() > GetSongLength()) { if (LoopSong) SetSongPosition(0); else { TogglePlaying(); SetSongPosition(GetSongLength()); ReachedEnd = true; } } } if (SongPlaying) { for (cur = 0; cur < samples; cur++) { // Get a sample from the MusicMap. slScalar value = GetMixerSample(persample); // Copy this sample into the audio. *(buf + cur) = value; // Since we're only making mono sound, // the right channel in stereo sound // should have the same data as left. if (stereo) *(buf + samples + cur) = value; } } else { for (cur = 0; cur < samples; cur++) *(buf + cur) = 0; if (stereo) for (cur = 0; cur < samples; cur++) *(buf + samples + cur) = 0; } }
void CTrack_DSP::DeleteRegion(tint32 iID) { std::list<SChannelRegionInfo*>::iterator it = mRegionInfoList.begin(); for (; it != mRegionInfoList.end(); it++) { if ((*it)->pRegion->GetID() == iID) { // Save pointer CRegion_DSP* pRegionDSP = (*it)->pRegion; // Remove entry mRegionInfoList.erase(it); SetSongPosition(muiSongPos); // Relase pointer delete pRegionDSP; return; } } // We didn't find any. Should we throw an exception? }
void CTrack_DSP::Update_Regions_For_Playback() { SetSongPosition(muiSongPos); }