+ 1

How to pass a variable to PlaySound()

I have a random number generator that produces 0-12 and that picks a random listing from a array with entries 1-13 that correspond to a n.wav (eg 12.wav) I want to pass the new variable ( randarr=5 = 5.wav) and pass that to play sound to play that WAV file. halp!?

8th Sep 2017, 10:41 PM
Bryce Pilny
Bryce Pilny - avatar
4 Respuestas
+ 5
You can convert the number to a String and then use String::ConCat( s1, s2). where s1 is the converted number and s2 is ".wav" then pass the result as PlaySound()'s first argument. Note this is not standard c++, but c++ .Net which it looks like you're using.
8th Sep 2017, 11:09 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
sorry I thought this was c++ only my bad
8th Sep 2017, 10:48 PM
Bryce Pilny
Bryce Pilny - avatar
+ 1
cool that gives me some directed research Thank you. this will eventually end up going in a raspberry pi zero. but I'm currently developing in codeblocks
8th Sep 2017, 11:11 PM
Bryce Pilny
Bryce Pilny - avatar
0
I could fill the array with "1.wav" if that makes a difference. then call arr[x] like PlaySound(TEXT(arr[x]), null, SND_SYNC)????
8th Sep 2017, 11:01 PM
Bryce Pilny
Bryce Pilny - avatar