Main Site Documentation

Wave playback


#1

Hi All

I’m trying to adapt the FEZ_Audio_Out sample from the samples page, and running into a few snags.

For one thing, it looks like the FEZ Panda supports reading through a whole buffer of voltages or something, as this line seems to show:

aout.Set(buffer, wav.GetDataIndex(), wav.GetDataSize(), wav.GetSampleRate());

Of course, the Spider only takes a single voltage.

So, before I go looping through that, I’m pretty sure I’m going to run into a problem where the Spider can’t keep up with spitting out samples like that from managed code (my past experience has shown that NEMF isn’t generally fast enough for this type of work). Has anyone tried this on the Spider?

Thanks.

Pete


#2

Ok, maybe time to modify approach.

If I wanted to use the regular NETMF/FEZ AnalogOut (not sure if that is even possible), any idea what pin I say it is connected to? IOW, what logical pin does the aout on socket 9 correspond to?

Thanks.

Pete


#3

Analog out pin is on “O” socket :slight_smile:


#4

But if I need to use the old NETMF AnalogOut instead of the Gadgeteer AnalogOut, I need to know the old-style (pre-socket) pin number to provide it. That’s what I need to ID here, as it doesn’t look like I can do wave playback natively from Gadgeteer code.

Pete


#5

There is only one analog out pin so it is an0 :slight_smile:

Basically, use the code toy found as is


#6

Aha! Simply adding references to the EMX libraries and using the EMX code worked.


#7

I’m actually porting an old Panda II project to the Cerberus-Mainboard.
I’m mostly done, but got one Problem:

The Panda offered the possibility of a wave-playback through the analog-out pin. So the e-block piezo could be used to play a wave-file.
Is there a possibility to do the same thing with the cerberus analog-out from the dac at sockets 4,3?

Additionally i’ve tested the music-module, but if added to the project, i get an out-of-memory exception. So ist would be nice to have the output without the module.


#8

@ FP - Welcome!

Yes, it has been added in the latest SDK.

http://wiki.tinyclr.com/index.php?title=NETMF4.2_developer
Check release notes. It is last item in the list.


#9

Thank’s for the fast feedback!

That sounds nice. So i could take the old e-block piezo, connect the signal (s-pin) to pin 5 of socket 3, add power supply to it an run?
Is there an example on how to control a single pin on the socket?


#10

Yes you get the socket first and then you can get to any pins.

Some examples in this thread:

http://www.tinyclr.com/forum/topic?id=7467


#11

Ok, then i create the socket like this:

GT.Socket.SocketInterfaces.AnalogOutput aout = GT.Socket.GetSocket(3, true, null, null).AnalogOutput;
Am I right?

Now I have the wave-data in a Byte-Array. Which method can be used to send the data to the output-pin?


#12

Actually all you need is to call this method:

public static void PlayPCMAudio(Microsoft.SPOT.Hardware.Cpu.AnalogOutputChannel channel, byte[] data, int offset, int count, int dataRate)

Member of GHI.OSHW.Hardware.Util


#13

And it is in premium as well, was added to both in last SDK release :slight_smile:

Welcome to the community.


#14

That sounds easy, but how can I find out, which one of the output channels is the one I’m searching for?

VS offers a list from Cpu.AnalogOutputChannel.ANALOG_OUTPUT_0 to Cpu.AnalogOutputChannel.ANALOG_OUTPUT_7. Is there a list to derive the right output channel on the cerberus sockets?


#15

Bing thanks to you guys. My application is now running properly.
ANALOG_OUTPUT_0 is representing pin 5 on socket 3.


#16

Good to hear. This should help in the future http://gadgeteer.codeplex.com/wikipage?title=Socket%20Type%20O


#17

I searched the web for a ducumentation of the GHI.OSHW.Hardware.Util.PlayPCMAudio(channel, data, offset, count, dataRate)-method, but without any result. Can anyone tell me, what the parameter “offset” is supposed to do? Is it a dc-offset?


#18

It is the starting offset in the byte array.


#19

Tanks again!


#20

You are welcome! :smiley: