frieza |
04-27-2014 03:07 PM |
pidgin midi sounds
this is a little shell script i wrote as an exercise to learn how to send raw MIDI commands to a midi device, as well as some basic shell scripting
it translates an input from pidgin for a .wav file into a series of midi commands using sed, amidi and a simple CASE statement
hope you find it useful if not simply a learning experience ^^
any suggestions on how i might be able to improve it would be appreciated ^^
the command to invoke it from pidgin is
Code:
/path/to/script/scriptname.sh %s
the script is
Code:
#!/bin/bash
######################################
# CONFIGURATION SETTINGS #
######################################
basepath='\/usr\/share\/sounds\/purple\/'
volume='4F'
inst='63'
note1='43'
note2='3F'
note3='5F'
note4='3B'
note5='5B'
note6='4B'
note7='4F'
chan='3' #channel numbers are 0 to 15
amidiflag='-p'
amididev='hw:1,0'
ext='wav'
######################################
# DO NOT EDIT BELOW HERE #
# UNLESS YOU KNOW WHAT YOU ARE DOING #
######################################
stripped="$(echo $1 | sed -e "s/$basepath//g" -e "s/.$ext//g")" #strip path and extention from file name
#
# these are the only sounds provided by a default pidgin install
# each one is assigned a unique pattern of notes
#
case $stripped in
"logout")
amidi $amidiflag $amididev -S "C$chan $inst"
amidi $amidiflag $amididev -S "9$chan $note1 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note1 00"
amidi $amidiflag $amididev -S "9$chan $note2 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note2 00"
amidi $amidiflag $amididev -S "9$chan $note4 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note4 00"
;;
"login")
amidi $amidiflag $amididev -S "C$chan $inst"
amidi $amidiflag $amididev -S "9$chan $note4 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note4 00"
amidi $amidiflag $amididev -S "9$chan $note2 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note2 00"
amidi $amidiflag $amididev -S "9$chan $note1 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note1 00"
;;
"send")
amidi $amidiflag $amididev -S "C$chan $inst"
amidi $amidiflag $amididev -S "9$chan $note5 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note5 00"
amidi $amidiflag $amididev -S "9$chan $note3 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note3 00"
;;
"receive")
amidi $amidiflag $amididev -S "C$chan $inst"
amidi $amidiflag $amididev -S "9$chan $note3 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note3 00"
amidi $amidiflag $amididev -S "9$chan $note5 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note5 00"
;;
"alert")
amidi $amidiflag $amididev -S "C$chan $inst"
amidi $amidiflag $amididev -S "9$chan $note6 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note6 00"
amidi $amidiflag $amididev -S "9$chan $note7 $volume"
sleep .4
amidi $amidiflag $amididev -S "9$chan $note7 00"
;;
esac
amidi $amidiflag $amididev -S "00 B$chan 7B 00" #all notes off
|