Friday 18 October 2013

Synth Pi

Having explored the inside of my Roland D10, I have decided to try and pimp it out with a Pi running Fluidsynth for a bit of fun.

Progress so far:

Installed fluidsynth:

sudo apt-get install fluidsynth

Installed ttymidi

sudo apt-get install libasound2-dev

wget http://www.varal.org/ttymidi/ttymidi.tar.gz
tar -zxvf ttymidi.tar.gz
cd ttymidi/
make
sudo make install

... then followed this from https://wiki.archlinux.org/index.php/USB_Midi_Keyboards

and have a working link to my USB controller (although slightly laggy)

Preliminary Testing

USB

First let us make sure that USB is working properly. When you type lsmod you should see some modules such as ehci, uhci or such. Also, when you type lsusb you should see something like:
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
This list might contain some USB devices if you have them plugged in or more or less items, depending on how many USB ports you have.

ALSA

You should have ALSA set-up properly (alsa-lib and alsa-utils packages). When you type lsmod | grep snd you should see a bunch of various snd drivers.
Try typing aseqdump. If you get an error stating that "aseqdump cannot find /dev/snd/seq" or similar, you might not have the snd-seq module loaded. To rectify that, type (as root)modprobe snd-seq. You might also want to add (again as root) snd-seq to your /etc/rc.conf file in the modules list. If the module is succesfully loaded, typing aseqdump should show something like:
Waiting for data at port 128:0. Press Ctrl+C to end.
Source_ Event_________________ Ch _Data__
Not much will show up there, so press Ctrl+C to quit the program.

Plugging the keyboard

Now plug the keyboard in and turn it on. The keyboard should power up. Output of lsusb should contain:
Bus 002 Device 002: ID 0a4d:00a0 Evolution Electronics, Ltd
Output of lsmod | grep usb should contain the following modules:
usb_midi               25348  0
snd_usb_audio          70592  0
snd_usb_lib            16640  1 snd_usb_audio
Now type aconnect -i. The output should contain:
client 72: 'MK-361 USB MIDI keyboard' [type=kernel]
    0 'MK-361 USB MIDI keyboard MIDI 1'
The client number is probably going to be different though. Take note of it.

Verifying Events

Type aseqdump -p ## where you should replace ## with the client number of your keyboard. You should see:
 72:0   Active Sensing
popping out all the time. Pressing a key should produce:
 72:0   Note on                 0  65  94
 72:0   Note on                 0  65   0
Various other events (turning control knobs, changing channels, etc.) should register in the list. This is a handy way of ensuring that your keyboard is running properly.

Playing

Now type aconnect -o to list the devices listed as ALSA midi outputs. It depends a lot on your sound card. On SB Live! Value, you get the following output:
client 64: 'EMU10K1 MPU-401 (UART)' [type=kernel]
    0 'EMU10K1 MPU-401 (UART)'
client 65: 'Emu10k1 WaveTable' [type=kernel]
    0 'Emu10k1 Port 0  '
    1 'Emu10k1 Port 1  '
    2 'Emu10k1 Port 2  '
    3 'Emu10k1 Port 3  '
Here client 65 is the actual MIDI synthesizer. Assuming the soundcard is set up properly, you should be able to route the output of the keyboard to the MIDI synthesizer. Assuming outis the output client number (65 in our example) and in is the input client number (72 in our example), type aconnect out in. Now you can play your keyboard via the MIDI output of your sound card.

To get it all working, I started Fluidsynth with:

fluidsynth -C0 -R0 -r22050 -a alsa /usr/share/sounds/sf2/FluidR3_GM.sf2

and in a ssh terminal I ran:

aconnect 20:0 128:0


Thursday 10 October 2013

Minidlna server

This works after a few reboots (not sure why) - All info from:

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=16352

I have seen several tutorials about minidlna server but, there was always something missing, so I want to share with you.

The idea is to use the RasPi as a multimedia server (in my case, for my PS3).

Hardware/Network configuration :
RasPi (I an under raspian, I use 2012-08-16-wheezy-raspbian)
External HD, or USB device, where media files are stored. Plug it to RasPi (USB)
PS3 (or any mediacenter to discover to RasPi media files)
(PC, ) RasPi and PS3 under to same sub-network

As I only have 1 screen for PS3 and RasPi, I did the configuration using ssh

[list=]Assuming IP adress table is :
PC : 192.168.0.11
PS3 : 192.168.0.14
RasPi : 192.168.0.16[/list]

In case of using ssh, Connect :

CODE: SELECT ALL
ssh pi@192.168.0.16


Enter password (default "raspberry"), then tty command line appears
CODE: SELECT ALL
pi@raspberrypi~:


I recommend updating everything before intallation :
Update package list:
CODE: SELECT ALL
sudo apt-get update

Update packages:
CODE: SELECT ALL
sudo apt-get upgrade


Mount hard drive automatically :
Use this command to discover UUID :
CODE: SELECT ALL
sudo blkid

You see your drive suck as :
CODE: SELECT ALL
/dev/sda1: LABEL="ExternalHD" UUID="49A1-143B" TYPE="vfat"


Make a directory where to mount the disk and change the autorizations:
CODE: SELECT ALL
sudo mkdir -p /media/HardDrive
sudo chmod 755 /media/HardDrive


Edit the fstab file :
CODE: SELECT ALL
sudo nano /etc/fstab


Add this line (using your UUID and TYPE) :
CODE: SELECT ALL
UUID=49A1-143B  /media/HardDrive   vfat    defaults      0     0


Install minidlna :
CODE: SELECT ALL
sudo apt-get install minidlna

It will warn you about how many disk space it will use and dependencies installation

Now you can configure minidlna:
CODE: SELECT ALL
sudo nano /etc/minidlna.conf


You see many options like :
CODE: SELECT ALL
# Change the Media Dir's to point to the external hard drive, obviously change these to match your directory layout
media_dir=A,/media/HardDrive/Media/Music
media_dir=V,/media/HardDrive/Media/Video
media_dir=P,/media/HardDrive/Media/Photos

# Change db_dir so that the database is saved across reboots
db_dir=/home/pi/.minidlna

# Uncomment log_dir for now in case we hit problems
log_dir=/var/log


You can choose to start minidlna at boot :
CODE: SELECT ALL
sudo update-rc.d minidlna defaults

Or just start it once now :
CODE: SELECT ALL
sudo service minidlna start


MiniDLNA will now begin indexing all of your media files, it's quite quick but folders not COMPLETELY indexed will not appear until they are done.

If you modify minidlna configuration, you have to reload it :
CODE: SELECT ALL
sudo service minidlna force-reload

Initial WiFi setup

This needs to be done through a wired network connection (obviously!) and correctly set up this USB wifi dongle:


Then follow the instructions from: http://www.raspberryshake.com/raspberry-pi-wireless-network-setup

but note: DELETE the contents of /etc/network/interfaces before adding the information at the end of the guide

Raspberry Pi Wireless Network Setup


Learn how to set up a wireless network using your Raspberry Pi and learn how to manage and use the various networking options that are available.
Plug in your wireless device into your Raspberry Pi or a USB hub.  I prefer to plug my devices into a USB hub to save the Raspberry Pi from wear and tear.
Before we can use the wireless device, we must first find out the name of our device so we can find the necessary drivers.  Enter the following command:
$ lsusb
This will list all the usb devices attached to our Raspberry Pi.  You will be looking for something that resembles your wireless device.  Search through the list of USB devices for a wireless adapter.
The result may differ depending on the devices you have attached.
Bus 001 Device 005: ID 0bda:8189 Realtek Semiconductor Corp. RTL8187B Wireless 802.11g Network adapter.
The key information listed above has been bolded.  This ID is what we will be searching for when looking for the drivers needed to use the adapter.
Before we continue, you will need to update your package information.  Be sure that you’re network cable is plugged in as we need to get some udpates from Debian.   Just enter:
$ apt-get update
When the updates have finished downloading, enter:
$ apt-cache search RTL818
Remember your device may be different, so you will be entering your device ID for your device.  You may have noticed that I only entered RTL818 instead of the whole ID.  This is because it didn’t find the adapter when using the apt-cache command.  You may need to shorten your description.

The result returned for my device was:
Firmware-realtek – Binary firmware for Realtek wired and wireless network adapters
Enter
$ sudo apt-get install firmware-realtek
After a few minutes of updating you will be back at your $ prompt.  Enter the following command to see if your adapter is listed.
$ lsmod
You will see the same ID of your device listed.
Module                                Size        Used by
rtl8187                                 44897          0
You can ignore the above details.  All we need to know is that the ID of your device is mentioned when you typed lsmod.
Now we just need to create a configuration file for the wireless adapter.  We are going to do this by create a file.  Enter the following command:
$ sudo nano /etc/wpa.config
Now enter the following, save the file and exit back to the $ prompt
network={
ssid=”YOUR_SSID”
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=”WPA-PASSWORD”
}
The last part of this configuration is to add a reference to the interfaces.   Issue the command:
$ sudo nano /etc/network/interfaces
Add the following
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.config
Save this file and exit.
The final stage of this process is to unplug your network cable as we want to test that the wireless device is actually working, so restart the network by entering:
$ sudo /etc/init.d/networking restart


Just a Braindump!

This is really just a braindump for myself for everything I've done with my Pi (mainly so I can remember HOW I did it if I ever need to do so again!)