Monday, February 8, 2016

Streaming NES (.NSF) file audio over a network using gstreamer

Now, to check on alsa
cat /proc/asound/cards should show some available cards

alsamixer should also work if you run it from the commandline. If alsamixer gives the following error:
cannot open mixer: No such file or directory

You may need to add yourself to the audio group in /etc/group, then log out and back in to update permissions.

First, we test remote piping of sound.

On the listening machine (Macbook Air for me, so using sox vs. aplay as you would/could in Linux):
nc -l 8000 | sox -traw -r44100 -b16 -e unsigned-integer - -tcoreaudio

On the source machine (Ubuntu 12.04 for me):
cat /dev/urandom | nc ip_addr_of_listening_machine 8000

If you hear white noise, the connection between machines seems to work correctly.

Next, we want to set up gstreamer

sudo apt-get install gstreamer0.10*

Check that we can play the .nsf files from gstreamer (where ${file} is the file to play)

gst-launch-0.10 -v filesrc location="${file}" ! nsfdec ! pulsesink 

You should hear the game audio of your choice. If this doesn't work, you may need to install libgme-dev by doing:

sudo apt-get install libgme-dev

Now you can try a file over the network.

gst-launch-0.10 -v filesrc location="${file}" ! nsfdec ! audioconvert ! wavenc ! udpsink port=8888

You can then connect to this port with netcat and listen to the wavenc encoded data (basically just raw PCM, if you missed the header).

nc sourceserver 8888 | sox -traw -r44100 -b16 -e unsigned-ineger -tcoreaudio

No comments:

Post a Comment