View unanswered posts | View active topics It is currently Sat Dec 20, 2014 10:20 pm






Reply to topic  [ 6 posts ] 
Sound file won't play when passed as variable 
Author Message
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Sound file won't play when passed as variable
I want to play an *.rso sound, and I want my program to dynamically concatenate the sound file name. However, when passing it to the PlaySoundFile() function, it doesn't play a sound -- even when the same PlaySoundFile() will work if I manually include the string value! I've tried to break it down to below code (it's not exactly what I'm using but should illustrate the issue in the minimal form):

Code:
string note = "1";
string soundFile = "sound/";
strcat(soundFile, note);
strcat(soundFile, ".rso");

if (soundFile == "sound/1.rso") { PlaySoundFile(soundFile); } // doesn't work!
if (soundFile == "sound/1.rso") { PlaySoundFile("sound/1.rso"); } // does work


(This even happens when I add a dummy "PlaySoundFile("sound/1.rso");" to the beginning of the program to make sure RobotC adds the sound file... what's a better way to do that, by the way?)

Can anybody help? Thanks!


Fri Nov 25, 2011 12:32 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: Sound file won't play when passed as variable
You need to change the path in the Preferences. Go to Preferences->NXT Directories and modify the NXT System Resources Files Directory.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Nov 25, 2011 5:37 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: Sound file won't play when passed as variable
Xander, this is what I did at the beginning. And note that the sounds play when I use the parameter "manually" (write a string value). But when passing the parameter as variable, it won't work anymore.


Fri Nov 25, 2011 5:46 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: Sound file won't play when passed as variable
That is very odd and sounds like a bug to me. Send a mail to support@robotc.net and let them know :)

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Nov 25, 2011 5:57 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: Sound file won't play when passed as variable
Thanks Xander. In the meantime, I'm switching to Frequencies via PlayTone...


Fri Nov 25, 2011 6:01 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: Sound file won't play when passed as variable
Oh very 8-bit old school :)

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Nov 25, 2011 6:04 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.