Silence from Music in 4.3 on new file-method

I have tried using the new file-read-method in the 4.3 music module driver. But cannot get it to work. There is just silence.

EDIT: Not complete silence, as the SineTest is working great!

What am I doing wrong?

Test-code:

using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHIElectronics.Gadgeteer;

namespace MusicTest1
{
    public partial class Program
    {
            
        void ProgramStarted()
        {
            Debug.Print("Program started");
            music.MusicFinished +=music_MusicFinished;
            sdCard.Mounted += sdCard_Mounted;
            music.RunSineTest();
            music.SetVolume(255, 255);
            if (!sdCard.IsCardMounted) sdCard.Mount();
        }

        private void music_MusicFinished(Music sender, EventArgs e)
        {
            Debug.Print("Finished playing this song");
        }

        void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
        {
            Debug.Print("Now playing..");
            music.Play(@ "\SD\DogBarkV2.mp3");
            //wait until audio is over
            while (music.IsBusy)
                Thread.Sleep(10);
        }
    }
}

you are seizing the event thread in the sd event handler?

I dont understand what you mean… :think:

your while loop is holding the event thread. if the music module is internally using events they will not get handled.

New testcode, still does not work…


namespace MusicTest1
{
    public partial class Program
    {
            
        void ProgramStarted()
        {
            Debug.Print("Program started");
            music.MusicFinished +=music_MusicFinished;
            sdCard.Mounted += sdCard_Mounted;
            music.RunSineTest();
            music.SetVolume(255, 255);
            if (!sdCard.IsCardMounted) sdCard.Mount();
            if (sdCard.IsCardMounted) {
                Debug.Print("Now playing...");
                music.Play(@ "\SD\DogBarkV2.mp3");
            }
            else Debug.Print("Not playing");
        
        }

        private void music_MusicFinished(Music sender, EventArgs e)
        {
            Debug.Print("Finished playing this song");
        }

        void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
        {
            Debug.Print("sd mounted..");
        }
    }
}

I would start the music playing in the sdCard_Mounted event handler.

Are you sure that the music.Play method is actually getting executed.

It take a while for the sdCard to get mounted.

Have you tried with a different music file?

I would try Mikes suggestion and kick it from the mounted event under it’s own THREAD… see if that makes a difference…

cheers,
Jay

As you see in the first version of the code, the Play is running in the sd-mount event-handler. That did not work, thats why I moved it to main.

If the filename is wrong, I get an exception which tells me that the SD-card is working fine…

Btw, the GHI re-org of documents has deleted the existing developer resources (which is a really bad thing I think!) so I cannot even check…

I will download the source, and see if there is something with the driver that can shed some light on the isssue.