Re: Transpose a complete MIDI file and save it to a new MIDI file (in batch mode)

From: Alexandre Ratchov <alex_at_caoua.org>
Date: Wed Jul 30 2008 - 21:56:48 CEST
On Wed, Jul 30, 2008 at 08:09:18PM +0200, laurent schwartz wrote:
> >
> > > I see a transpose proc in midish manual. I would like to transpose a
> > > complete MIDI song (every notes) one or more halftone down or up and save
> > it
> > > to a new MIDI file.
> >
> > >>drums can't be transposed. on the other hand midi files don't
> > >>contain information to distinguish drums from chromatic
> > >>instruments. But luckily most songs use channel 9 for drums, so you
> > >>can just skip it, ie transpose channels 0..8 and 10..15 only:
> >
> 
> wikipedia says channel 10 (but midish numbered channels from 0 to 9)
> 
> Thanks for your quick answer.
> 
> I've join to this post the bash shell i'm using to create new midi song and
> wav output (you will need timidity and latest midish snapshot).
> 
> example: ./transpose.sh file.mid \-1 dest_file.mid
> 

thanks!

since i dont have bash installed i've slightly modified it to work
in my environment, below is the diff. It also contains minor
tweaks.

 - checking that $3 exists doesn't work, since it will
   be created by timidity

 - declare keyword doesn't exist on all shells

 - ``midish -b'' command is more appropriate for scripting;
   The -b flag turns off interactive mode, allowing better
   error handling and skipping /etc/midishrc and ~/.midishrc
   files.

-- Alexandre

--- transpose.sh.old	Wed Jul 30 21:43:31 2008
+++ transpose.sh	Wed Jul 30 21:45:23 2008
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 usage (){
 	echo "Usage: $0 file.mid nb_halftone dest_file.mid"
 	echo ""
@@ -16,15 +16,11 @@ if [ ! -f $1 ]
 then
 	usage 
 fi
-if [ ! -f $3 ]
-then
-	usage
-fi
-declare -i trans
+
 trans=$2
 
 echo "Creating $3 midi file transposing $2 halftone ..."
-rmidish > /dev/null 2>&1 <<EOF
+midish -b <<EOF
 import "$1"
 sel 10000
 ev {any {0 0..8}}
Received on Wed, 30 Jul 2008 21:56:48 +0200

This archive was generated by hypermail 2.1.8 : Wed Nov 08 2017 - 16:32:20 CET