Bad access on vector of ofSoundPlayers when I try to mute them?

Hey, I’m trying to add a mute function to my game. I have pointers to all of my ofsoundplayers stored in a vector in my MusicHandler class, and a separate vector of their volumes.

here’s my mute code:

void MusicHandler::mute()
{
    if (!MUTE)
    {
        trackVols.clear();
        for (int t = 0; t < allTracks.size(); t++)
        {
            trackVols.push_back(allTracks[t]->getVolume());
            allTracks[t]->setVolume(0);
        }
    }
    else
    {
        for (int t = 0; t < allTracks.size(); t++)
        {
            allTracks[t]->setVolume(trackVols[t]);
        }
    }
    
    MUTE = !MUTE;
}

in testApp I just have an on keypress ‘m’, musichandler.mute(). I’m getting a bad access on that line, although it does seem to be entering the mute function.

Any obvious issues here? Am I overcomplicating this?

Not totally sure how I did it, but this is working now.

I assigned the individual volumes to a float before pushing them into the vector, and I moved my track initialization and vector addition to MusicHandler’s setup instead of the constructor.