View unanswered posts | View active topics It is currently Mon Sep 01, 2014 6:46 pm






Reply to topic  [ 9 posts ] 
RSO sound cannot be found (or wrong file played) 
Author Message
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post RSO sound cannot be found (or wrong file played)
I have a program with 12 sound files. However, half of them can't be played.

Code:
PlaySoundFile("sound/c/1.rso") // works
// .. and somewhere else in the code, after time passed, and even when using ClearSounds()...
PlaySoundFile("sound/f/1.rso") // doesn't work... or plays c/1 sound instead of f/1


All these files are in my project (as per my computer), and RobotC also doesn't complain about not finding them. It just doesn't play them during execution. I tried renaming the files in various ways, or not using folders etc., to no avail.

Can anybody help?

Thanks in advance!


Fri Nov 25, 2011 1:59 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: RSO sound cannot be found (or wrong file played)
Could you post the entire program?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Nov 25, 2011 4:07 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: RSO sound cannot be found (or wrong file played)
Something like this:

Code:
#pragma config(Sensor, S3, touchSensor, sensorTouch)
#pragma config(Sensor, S4, colorPort, sensorCOLORFULL)

void colorToSound();
void resetDidPlayNote();
void soundDummy();
task ButtonTask();

int scale = 1;
const int maxNotes = 6;
bool didPlayNote[maxNotes];

task main() {
    soundDummy();
    resetDidPlayNote();
    nNxtButtonTask  = ButtonTask;

    while (true) {
        if ( SensorValue(touchSensor) == 1 ) {
            colorToSound();
        }
        else {
            resetDidPlayNote();
        }
        wait1Msec(50);
    }
}

void resetDidPlayNote() {
    int i;
    for (i = 0; i < maxNotes; i++) { didPlayNote[i] = false; }
}

void colorToSound() {
    string note = "0";
    switch (SensorValue[colorPort]) {
        case BLACKCOLOR: note = "1"; break;
        case REDCOLOR: note = "2"; break;
        case GREENCOLOR: note = "3"; break;
        case YELLOWCOLOR: note = "4"; break;
        case BLUECOLOR: note = "5"; break;
        case WHITECOLOR: note = "6"; break;
    }
    int iNote = atoi(note);
    string scaleName = "c";
    switch (scale) {
        case 1: scaleName = "c"; break;
        case 2: scaleName = "f"; break;
    }

    if (iNote != 0 && !didPlayNote[iNote - 1]) {
        // PlayTone(500 + note * 100, 1);

        resetDidPlayNote();
        didPlayNote[iNote - 1] = true;

        string soundFile = "sound/";
        strcat(soundFile, scaleName);
        strcat(soundFile, "/");
        strcat(soundFile, note);
        strcat(soundFile, ".rso");

        nxtDisplayTextLine(2, "Scale %s", scaleName);
        nxtDisplayTextLine(3, "Note  %s", note);
        nxtDisplayTextLine(4, "%s", soundFile);
        ClearSounds();

        // passing soundFile as variable didn't work so far (see other thread question), hence this workaround
        if     (soundFile == "sound/c/1.rso") { PlaySoundFile("sound/c/1.rso"); }
        else if (soundFile == "sound/c/2.rso") { PlaySoundFile("sound/c/2.rso"); }
        else if (soundFile == "sound/c/3.rso") { PlaySoundFile("sound/c/3.rso"); }
        else if (soundFile == "sound/c/4.rso") { PlaySoundFile("sound/c/4.rso"); }
        else if (soundFile == "sound/c/5.rso") { PlaySoundFile("sound/c/5.rso"); }
        else if (soundFile == "sound/c/6.rso") { PlaySoundFile("sound/c/6.rso"); }

        else if (soundFile == "sound/f/1.rso") { PlaySoundFile("sound/f/1.rso"); }
        else if (soundFile == "sound/f/2.rso") { PlaySoundFile("sound/f/2.rso"); }
        else if (soundFile == "sound/f/3.rso") { PlaySoundFile("sound/f/3.rso"); }
        else if (soundFile == "sound/f/4.rso") { PlaySoundFile("sound/f/4.rso"); }
        else if (soundFile == "sound/f/5.rso") { PlaySoundFile("sound/f/5.rso"); }
        else if (soundFile == "sound/f/6.rso") { PlaySoundFile("sound/f/6.rso"); }
    }
}

task ButtonTask() {
    switch (nNxtButtonPressed) {
        // case kLeftButton: ; break;
        // case kRightButton: ; break;
        case kEnterButton:
            const int maxScales = 2;
            scale++;
            if (scale > maxScales) { scale = 1; }
            break;
   }
   return;
}

void soundDummy() {
    // PlaySoundFile("sound/c/1.rso");
}


Fri Nov 25, 2011 4:28 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: RSO sound cannot be found (or wrong file played)
Your code looks fine, but I can't really test it without the sound files. Can you attach them to a post?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Nov 25, 2011 4:42 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: RSO sound cannot be found (or wrong file played)
Here they are, thanks: http://versuspad.com/file/robotc-sound.zip


Fri Nov 25, 2011 5:02 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: RSO sound cannot be found (or wrong file played)
I just tested it, and it's working perfectly. I didn't modify anything. Is there actually a difference in the scales yet? They sound the same to me.

Are you using the latest version of RobotC? The latest firmware? Cause' I'm not seeing anything wrong.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Nov 25, 2011 6:07 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: RSO sound cannot be found (or wrong file played)
Quote:
Is there actually a difference in the scales yet? They sound the same to me.


Well, that's the problem -- they sound the same to me too. However, the original WAV files are different, and for what it's worth the RSO files also have different file sizes. Hmm.


Fri Nov 25, 2011 6:37 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: RSO sound cannot be found (or wrong file played)
Well, I've only used a couple of converted sound files before(and that was with NXT-G), so I'm not sure what else I can do. I've heard before that there have been problems with sounds in RobotC. Try contacting support and see what they say.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Nov 25, 2011 7:20 pm
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 10:45 am
Posts: 12
Post Re: RSO sound cannot be found (or wrong file played)
Thanks! I've been sort of switching to the PlaySound/ Frequency approach now as alternative.


Fri Nov 25, 2011 7:40 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 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.