Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a specific task I want to accomplish...I am trying to figure out if there is an a way of doing this. Basically, for a project I am working on, I want to create sound files for individual music notes.

So, for example, a piano playing a single "A" sound would be one file. A piano playing a "B" sound would be another file.

I would like to do this for a large number of instruments. I know that Mac OS has midi instruments built-in. I been able to create the sorts of files I am looking for by hand in Garage Band by playing a software instrument, saving the file, then altering the pitch.

This is time-consuming, however, and I think the process could be automated. Maybe if I could create a midi file with the command line and then convert that midi file to a sound file, I could do it with a shell script?

Does anybody have any recommendations to put me on the right track?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The solution that I used involved abc2midi and Amadeus Pro, although it seems I could have used FluidSynth if I wanted to go full command line. Basically, I made a template abc file that looked like this

X:1
M:4/4
K:C
%%MIDI program number
note z

then I replaced "number" and "note" with a shell script that looked like this

#/bin/sh

for i in {0..127}
do
    for j in C ^C D ^D E F ^F G ^F A ^A B c ^c d ^d e f ^f g ^g a ^a b c\'
    do
        sed "s/number/$i/g" template | sed "s/note/$j/g" > $i$j.abc
    done
done

for file in *.abc
do
    abc2midi $file
done

At that point, this basically gave me a folder full of midi files that I could then use a synthesizer to turn into wav files. Here, I batch processed them with Amadeus Pro (which is a commercial application).

I understand that a command line synthesizer like FluidSynth might have also worked, but this was only one (small) step in my project and I was trying to do this in the fastest way possible, not make the most elegant solution, so I didn't take the time to get that running and add it to my shell script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.