Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - marqss

Pages: [1]
1
Audio / Multiscope sound access
« on: May 19, 2015, 01:44:15 pm »
I would like to know if there is a way to access an instance of sf::sound or sf::music in a scope different than where it is declared and/or loaded? Eg declare a sound in main() but play() it in another function or vice versa?
The code below gives me errors on sm.play() ("undeclared identifier" and "left of '.play' must have class/struct/union")

void playwilhelm(int i=1000)
{
       
        sm.play();
        cout << "\nScream should be played now\n";
        Sleep(i);
        cout << "\nEnd Scream\n";
}

int main()
{
        sf::SoundBuffer wilhelm;
        wilhelm.loadFromFile("music\\wilhelm scream.wav");
        sf::Sound sm;
        sm.setBuffer(wilhelm);
        sm.setVolume(50);

        playwilhelm (2000);
 

Also, I imagine it's not possible but correct me if I'm wrong: I can't use a variable when setting up audio to play, eg when calling sf::Sound x, can I?

Pages: [1]