Automated sampling in linux

Share and download User samples and project files (*.nsmp, *.nsmp3, *.nsmp4, *.nsmproj)"
Forum rules
How to get the MP3-Player:
Upload a MP3 file where you play some notes using your sample.
Click the "PLACE INLINE" button after uploading the MP3 sample in order to automatically create a Flash MP3 player in your post!
Also check the Forum Rules, in particular rule #6 about the sharing of patches and samples.
Post Reply
User avatar
Mr_-G-
Former Team Member
Posts: 4760
Joined: 18 Aug 2012, 16:48
13
Your Nord Gear #1: Nord Stage 2
Has thanked: 1470 times
Been thanked: 1273 times

Automated sampling in linux

Post by Mr_-G- »

I have written a small script that allows sending from linux a range of MIDI notes of desired duration and velocity to a selected MIDI port (and therefore a synth).
If you connect the audio output of the synth to the computer audio in, you can record the result in audacity or similar as a single WAV file, which is convenient when using the sample editor.

Code: Select all

#!/bin/bash
# PlayNotes sends a stream of MIDI notes to a synth for automated sampling
# by Mr_-G-
# 29/08/2015
midiport=$(amidi -l | grep -i Nord | grep -i Stage | cut -d ' ' -f 3) # detect automatically Nord Stage among midi ports
echo $midiport
silence=0.5
gate=1
vel=127

# c1 to c9 in steps of n
for i in {12..108..4};
do
   sleep $silence
   note=$(printf "%x\n" "$i")
   velo=$(printf "%x\n" "$vel")
   midi="90 $note $velo"
   echo -e "\\e[0;31m\\033[1mNote On : $midi \033[0m"
   amidi -p $midiport --send-hex=$midi
   sleep $gate
   velo=$(printf "%x\n" "0")
   midi="90 $note $velo"
   echo -e "\\e[1;33m\\033[1mNote Off: $midi \033[0m"
   amidi -p $midiport --send-hex=$midi
done  
In this case it sends the MIDI stream to my NS2 port. You can change to which port to send the MIDI notes. First find the ports available in your computer via the command typed in the terminal

Code: Select all

amidi -l 
and modify the code accordingly.

The variables to tweak are:
silence (the gap betwen played notes, default 0.5 sec)
gate (the number of seconds the note is played, default 1 sec)
vel (the MIDI veolcity value, default 127)
The line

Code: Select all

for i in {12..108..4};
specifies which is the starting note (12), the ending note (108) and the step in semitones (4).

To run it, copy the code above into a text file, save it as 'PlayNotes', make it executable and run it from the folder location in the terminal window by typing:

Code: Select all

./PlayNotes
It should send the notes sequentially to the specified MIDI port and also print ON OFF messages to the screen.

All commands used in the code should be available in a modern linux distribution.
This comes with no guarantees of any kind, but posted it in the hope that it is useful to others.
Please post any modifications or improvements (and your sample masterpieces too!).
These users thanked the author Mr_-G- for the post (total 3):
Frantz, elektromin, dmamfmgm
User avatar
Darren
Patch Creator
Posts: 368
Joined: 06 Sep 2012, 21:55
13
Your Nord Gear #1: Nord Stage 2
Your Nord Gear #2: Nord Wave
Location: Cheltenham, UK
Has thanked: 33 times
Been thanked: 189 times
Great Britain

Re: Automated sampling in linux

Post by Darren »

I like it! Simple and elegant - Thanks for sharing.
Nord Stage 2 HA76, Nord Wave, CME UF60, Studiologic VMK 161 Plus Organ, Roland Juno G, Yamaha P200, Yamaha TG77, Roland U-220, Kawai K3M, Roland Juno 60, Fender Rhodes Stage 73
User avatar
Frantz
Patch Creator
Posts: 2261
Joined: 30 Apr 2011, 13:12
14
Your Nord Gear #1: Nord Electro 5
Location: ♫♪ earth ♪♫
Has thanked: 465 times
Been thanked: 550 times
Contact:
France

Re: Automated sampling in linux

Post by Frantz »

Cool :) like it too !! Thx
http://displaychord.arfntz.fr
A mobile app to display chord names while you play, using midi / bluetooth connection.
Post Reply