MIDI instrument for typical orchestral samplers, keyswitches, etc

Hi, I’m very new to Scamp and I have worked through the first tutorial video and poked around the reference a little. I see that an Instrument can be defined as a MIDI instrument. I’m interested in using Scamp with orchestral samplers that typically put different articulations or effects on keyswitches or different patches (channels) or what have you. Can Scamp do something like this? Can it be customized to a particular sampler?


Hi Mike — welcome! Sorry for the slow response.

Here’s one way to do what you’re suggesting:

from scamp import *

s = Session()
cello = s.new_midi_part("cello", 0)

last_ks = None

ks_to_midi_pitch = {
    "arco": 84,
    "tremolo": 85,
    "staccato": 86

def play_cello_note(pitch, volume, duration, properties=None, keyswitch="arco"):
    global last_ks
    if keyswitch != last_ks:
        cello.play_note(ks_to_midi_pitch[keyswitch], 1.0, 0.05, blocking=False)
        last_ks = keyswitch
    cello.play_note(pitch, volume, duration, properties=properties)
play_cello_note(48, 0.7, 0.25, keyswitch="staccato")
play_cello_note(49, 0.7, 0.25, keyswitch="staccato")
play_cello_note(50, 0.7, 0.25, keyswitch="staccato")
play_cello_note(53, 0.7, 1.25, keyswitch="tremolo")
play_cello_note(52, 0.7, 0.5, keyswitch="arco")
play_cello_note(51, 0.7, 0.5, keyswitch="arco")

Here, ks_to_midi_pitch defines a mapping from articulation names to keyswitch pitches, and anytime the keyswitch is different from the last keyswitch, it sends a very short note to the appropriate pitch to change keyswitch right as the note is starting.

This works for me on my computer, and I think it should be pretty reliable. Of course, it does mean you’re creating a new function for playing notes from each instrument, so there’s probably a cleaner way to do it using classes.

Hope this helps!

Thanks, Mark. Yeah I was thinking more along the lines of customizing the Instrument class. I’m presuming that Instruments can be used in multiple contexts and they are a kind of abstraction. SCAMP already has the ability to associate an articulation with a note if I remember right, so the question is whether an instrument can be customized to play or export to a MIDI file to handle this. It’s not just keyswitches; many of these samplers put different articulations on different channels.

I’m sure it can be done if I’m willing to delve into the code. I’m just wondering if it has been done already.

Thanks again.

There’s no native implementation, but it’s definitely something I’ve been thinking about the most convenient/flexible way of incorporating! And for now, as you can see, there are more or less hacky ways of accomplishing this.