I needed to grab a few sounds from my aging ESQ-1 as I may retire it soon, and want some of the sounds to survive. I shall post a few as soon as it's done.
I had a challenge to play the tones I needed because several reasons:
- sometimes I need different velocity (not always 127)
- some sounds evolve over several seconds, I think the longest so far is 9 secs for each tone
- For size constraints I needed to cut down on number of sampled keys for each sound and also again the length. Some sounds only needed about 1 sec of sample time
- incorporating all this into a midi files seemed to cumbersome...
I've been messing around with python before, so it made sense to look for a solution. And I manages to make a simple Python program to do this for me. You have to have Python installed as well as the package "mido". YOu change the parameters explained above in the "User settings" section. First you must run the program to ID your MIDI device and enter that into the main program.
I have no Idea if this is useful to anyone or if it makes any sense. I will help if I can.
Martin
ID PROGRAM:
Code: Select all
import mido
import time
import numpy as np
print(mido.get_output_names()) # To list the output ports
print(mido.get_input_names()) # To list the input ports
Code: Select all
#
#
# Install mido: https://mido.readthedocs.io/en/latest/installing.html
# Notes and frequencies: https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies
# Source and contact: https://www.norduserforum.com/nord-user-samples-nsmp-samples-f14/python-midi-tone-generator-to-generate-samples-t22072.html
#
import mido
import time
import numpy as np
###############################################################################################################
###################
## USER SETTINGS ##
###################
current_note_velocity = 127 # Enter value from 0-127.
step = 1 # Half noters to step through for each new note
start_note = 30 # Start note 0-127 (middle C=60) (low c 61-keys = 36) (low c 88-keys 21)
end_note = 100 # End note 0-127 (middle C=60) (high c 61-keys = 96) (high c 88-keys 108)
tone_length = 8 # tone length in secs ex 1.2
silence_length = 2.5 # silence tbehtween tones in secs ex 0.8
###############################################################################################################
midi_device_in = '3- AudioBox USB 96 MIDI In 0'
midi_device_out = '3- AudioBox USB 96 MIDI Out 1'
#print(mido.get_output_names()) # To list the output ports
#print(mido.get_input_names()) # To list the input ports
print('Opening MIDI ports...')
print('In: ' + midi_device_in)
print('Out: ' + midi_device_out)
inport = mido.open_input(midi_device_in)
outport = mido.open_output(midi_device_out)
# Create a list of notes to play
notes_to_play = np.arange(start_note, end_note, step).tolist()
# Print messages
print('Playing ' + str(len(notes_to_play)) + ' notes')
print('With velocity ' + str(current_note_velocity))
note_count = 0
# Play notes
for current_note in notes_to_play:
msg = mido.Message('note_on', note=current_note, velocity=current_note_velocity)
note_count = note_count + 1
print('note ' + str(note_count) + ' of ' + str(len(notes_to_play)) + ' - ' + str(msg))
outport.send(msg)
time.sleep(tone_length)
msg = mido.Message('note_off', note=current_note)
outport.send(msg)
time.sleep(silence_length)
print('Done')