Problem FEZ MUSIC SHIELD (Driver)

I’m using FEZ MUSIC SHIELD and I have a problem when trying to use this shield type in a while loop.

I copied the code from this link:

http://code.tinyclr.com/project/344/music-shield-extension-playing-streams/

The trouble is that the sound is cutting out when it goes in the loop, even putting a condition to perform once the sound is still cutting.

If you do not put the loop the music plays without any problems.

Someone could help me, if they want to put my code.

Maybe the options are to use lower bitrate or use RLP? Similar topics came up before

Can you show your code, please?

@ Arch

As I described earlier I am using the following classs MusicShield, see the link below:

http://code.tinyclr.com/project/344/music-shield-extension-playing-streams/

Follow my code bellow:


using System.IO;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.FEZ.Shields;
using GHIElectronics.NETMF.IO;

namespace FEZMusicShield
{
    public class Program
    {
        public static void Main()
        {
            InputPort button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di2, false, Port.ResistorMode.PullDown);

            while (true)
            {
                if (button.Read())
                {
                    Play();  
                }
            }
        }

        public static void Play()
        {
            MusicShield musicShield = new MusicShield(SPI.SPI_module.SPI1, FEZ_Pin.Digital.An4, FEZ_Pin.Digital.An5, FEZ_Pin.Digital.Di4);
            musicShield.SetVolume(200, 200);

            if (PersistentStorage.DetectSDCard())
            {
                PersistentStorage sdCard = new PersistentStorage("SD");
                sdCard.MountFileSystem();

                Debug.Print("Testing Playback...");

                FileStream fs = new FileStream(@ "\SD\PinballMap.mp3", FileMode.Open);
                musicShield.Play(fs);
            }
        }
    }
}

First, try putting a sleep in the loop


           while (true)
            {
               Thread.Sleep(100);
                if (button.Read())
                {
                    Play();  
                }
            }

@ Mike

success!!!

Thank you! :smiley: