Main Site Documentation

Long wait for the music module's isReadyRecord


#1

Hi,

Perfect newbie here :open_mouth:
The music module is taking a long time (~90 seconds) to pass the

 block. Is it normal that it takes so long? I'm using a FEZ Spider.

Thanks, 
Davide

#2

Can you show the rest of your code? Can you try it on a different S socket on the Spider? Or with a different music module or mainboard if you have any.


#3
  • Different S socket: no difference.
  • Different music module: no difference
  • Different Spider: will try that in a moment and get back.
  • Code: below (hope that’s everything that is needed)

            if (isRecording)
            {
                try
                {
                    multicolorLed.BlinkRepeatedly(GT.Color.Yellow);
                    iAudioAttempt++;
                    string strFilename = "Record_" + iAudioDuration.ToString() + "_" + iAudioAttempt.ToString()
                        + "-" + System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString()
                        + "-" + System.DateTime.Now.Day.ToString() + "_" + System.DateTime.Now.Hour.ToString()
                        + "-" + System.DateTime.Now.Minute.ToString() + "-" + System.DateTime.Now.Second.ToString()
                        + ".ogg";
                    using (FileStream recordingFile = sdCard.GetStorageDevice().OpenWrite(strFilename))
                    {
                        music.RecordOggVorbis(recordingFile, Gadgeteer.Modules.GHIElectronics.Music.patch_ogg);

                        Debug.Print("Waiting for the module to be ready");

                        while (!music._isReadyRecord) ;
                        multicolorLed.TurnColor(GT.Color.Red);
                        Debug.Print("Starting recording...");

                        // record for 'iAudioDuration' seconds
                        Thread.Sleep(iAudioDuration * 1000);

                        stopRecording();
                    }
...

        void stopRecording()
        {
            isRecording = false;
            music.StopRecording();

            // Wait until recording is done
            while (music.IsBusy)
                Thread.Sleep(10);

            Debug.Print("Recoding is done.");
            // Unmount the SD card
            sdCard.UnmountSDCard();
            multicolorLed.TurnColor(GT.Color.Orange);
        }


#4

I would thread.sleep(10) in that wait loop as well to allow other stuff to run. Not saying it’s related but I’d make that change anyway…


#5

@ Brett - As a matter of fact that has taken the waiting time down from about ~90 seconds to about ~50. Still very long but much better. Any idea why that is?

Thanks.


#6

When you start recording, the patch has to be sent to the device. In total it looks to be about ~55KB for the built in patch. On the Spider, all of those 50 seconds are spent preparing and sending the patch. Increasing the SPI clock does not help much. Switching to the Raptor brought it down to ~3 seconds though.