Recording and Playing a steam with the Music Module

Hello,

I have just started using the Music Module and have realised that the Play() method wants a byte array but I would like to play a file larger than the 4.5mb flash memory on the Spider. When I try and play my file I get a System.OutOfMemoryException (I can’t remember the exact exception name but it’s to that effect).

I am playing the sound files from an SD Card using the SD module which can return a System.IO.FileStream object to the file, but the music module doesn’t seem to be able to take a FileStream object as input.

Is there any way around this? Or any plans for writing a way to play a FileStream rather than a byte dump? Or will I just have to work with smaller sound files?

On a seperate note, I was just looking at the RecordOggVorbis() function for audio in and was wondering how we use this function? I don’t really understand what the parameters are asking for.

Thanks for your time,

Poncho

You only need a simple change te the music module driver source to allow it to play from a “stream”.

I’ve posted an example here: http://code.tinyclr.com/project/431/music-module-driver-accepting-streams/

Hi,

What version of the music assembly are you using? version GTM.GHIElectronics.Music.dll, v4.0.30319 did’nt have the Play method which take a stream.

Thanks

Dick

Dick,

I’m not using the default driver, but a modified one. You can find the sourcecode on the bottom of this page: http://code.tinyclr.com/project/431/music-module-driver-accepting-streams/

Oh yes ! Wonderful. Why your code isn’t in the official labrary?

Btw, that’s the first time I ear some music form my module. I find the sound nasty… do you have the same feeling?

It’s up to GHI if they want to put my code in the official driver. I don’t think a semi-beginner like me is in the position to decide on that.

I did have stuttering with some 192kbps MP3’s, but not all the time. A 128kbps MP3 played fine. I also managed to play a 128kbps MP3 stream from internet for more than 5 hours without interruption.

Because it is a community contribution but since it is a very nice contribution it may move to the official SDK.

There is an event driven joystick driver that is very nice as well.

@ Gus

Joystick? Or are you referring to the event-driven Potentiometer driver that Mischa dropped on the code site this week?

Oh yes pot not joystick :slight_smile:

Mischa,
What code are you using to get the audio stream from the Internet? I can only get 32 kbs to play without stuttering with the following:


     HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://integral-data.com/NewYorkNewYork_32kbs.wma");
     music.Play(httpWebRequest.GetResponse().GetResponseStream());
     while(music.IsBusy)
          Thread.Sleep(10);
     httpWebRequest.Dispose();

Mike,

The code I used is far from completion and probably has more bugs than lines of code. :-[ I put the streaming project to the side untill I have more experience with .NETMF.

What I did was create a new thread that reads chunks of data from the ResponseStream and writes it to a MemoryStream. I then send the MemoryStream to the music module.

You are too modest, Mischa. The driver is fine for the SD Card, and it makes it possible to use a Stream from Internet. My low-bandwidth usage online is far better than not being able to load files larger than 600k.
If you don’t mind, I’ll write this up as an example on my blog with all the steps to using your driver with Stream parameter of Play method.

Hi Mike,

You are not really playing a stream. In fact, your are downloading a mp3 file throught a http stream and then play the mp3 file.

Do you try to play a streaming shoutcast like this http://play.internet-radio-guide.net/asx.php?id=164171?

I tried without success.

Dick

It is not streaming audio per se, but it is using a Stream object, which makes it feasible to play files larger than the memory of the mainboard. This file cannot be played by downloading it to byte[] array,

Here is the example: GHI Electronics Music Module Play method using FileStream or MemoryStream | Integral Design Maybe I’m missing something.

Hi,

No sorry, I missed something. I was to focus on my needs. I want to play a web stream shoutcast and I didn’t find a way to do it.

Thx

Dick

Have you tried the streaming feature in Windows Media Player?

Yes, but my needs is to have a MediaElement like in Gadgeteer :slight_smile:

Dick

This modified driver is great but I have some problems using it with the micro framework 4.2

I expirience enormous stottering with 128kbps files from the very first second.
Does anyone else have this problem and does anyone know what to do against it?

btw: I’m using the FEZ Spider

@ Andre, thanks this looks promising.
But as far as I can see it’s just for the Panda II board and as I said before I’m using the Spider 1.
I don’t know if njbuch is capable and willing to port the project to the spider…

I’m pretty sure managed code is the reason for the stottering.
The funny thing is: With the .net mf 4.1 it was working (using the modified driver from Mischa).

I really don’t know if I’m able to help njbunch, 'cause I’m not used to write native c/c++ code…