1
Audio / I'm missing something fundamental RE threads and audio
« on: June 14, 2009, 03:21:46 pm »
Yes, of course. Thanks again for your attention! Off to build some rockets...
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
void MainFrame::OnFileListItemSelected( wxListEvent& WXUNUSED(event) )
{
std::string filename = this->wx2std(this->GetSelectedFile());
sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile(filename)) return;
this->Sound->SetBuffer(Buffer);
this->Sound->SetVolume(100.f);
this->Sound->Play();
}
void MainFrame::OnFileListItemSelected( wxListEvent& WXUNUSED(event) )
{
std::string filename = this->wx2std(this->GetSelectedFile());
sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile(filename)) return;
sf::Sound Sound;
Sound.SetBuffer(Buffer);
Sound.SetVolume(100.f);
Sound.Play();
}
// Event handler for a wxListCtrl selection event...
void MainFrame::OnFileListItemSelected( wxListEvent& WXUNUSED(event) )
{
std::string filename = this->wx2std(this->GetSelectedFile());
sf::Thread Thread(&ThreadFunction, &filename);
Thread.Launch();
}
void ThreadFunction(void* UserData)
{
std::string* str = (std::string*)UserData;
sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile(*str)) return;
sf::Sound Sound;
Sound.SetBuffer(Buffer); // Buffer is a sf::SoundBuffer
Sound.SetVolume(100.f);
Sound.Play();
while(Sound.GetStatus() == sf::Sound::Playing) {
sf::Sleep(0.1f);
}
}