Controlling midi channels

Hi Mark,
First - I discovered scamp a few months ago and loving it. Brings together so many tools into a great work flow. Thank you!

Q: I’m trying to control different orchestra articulation samples using midi channels. I have a set of midi_parts that I’ve built. Can i change the midi channel for each part dynamically, after the start_channel is set? I assume this is in MIDIStreamPlaybackImplementation but i can’t figure out how to access or set it.

I saw the keyswitch answer but wondering if we can do it by switching channels.

For reference, using Logic orchestra sample banks.

Thanks!
Neil

Actually - i’m retracting this question. After investigating keyswitches, I now understand that this is exactly what I’ve been looking for all along. Great to have this forum. Thanks!

Glad you sorted it out!

Yeah, I guess SCAMP doesn’t really allow you to specify channel on a per-note basis. (The channel juggling is complicated enough as it is!) But you can always use start_channel=x and num_channels=1 to force an instrument object to use a particular channel.

It looks like you’re really investigating the code-base! One of my ongoing goals is to reduce coupling between the modules and make it easier for other people to make contributions. So hopefully it gets gradually less overwhelming.

Keyswitches turned out not to be as useful as I expected. The behaviour I’m getting in Logic is that articulation sets are applied universally so that if you do a keyswitch in the flute part (say legato to staccato) it will also affect the timpani and string parts, when you are playing the sampler directly from your scamp scripts. If anyone can explain to me how to make this work when using a full sampler orchestra to listen to your scamp scripts that would be greatly appreciated…

Back to exploring channel switching. I made a little script that removes and then adds new midi device and channel.

def change_midi_channel(inst, device, channel):
    '''
    inst: ScampInstrument with midi playback implementation
    device: string - currrent or new midi device/port name
    channel: int - new midi channel
    '''
    inst.remove_streaming_midi_playback()
    inst.add_streaming_midi_playback(device, 1, start_channel=channel)

Is there a way to see what the current channel and device are for an object? I can’t figure out where to access these variables for any given instrument. I have some gremlins when I try to insert this into more complex gestures that are hard to pin down.

Thanks!
N

So, in Logic, is each articulation on a different channel of the same midi track?

If so, I wonder if this MultiPresetInstrument extension in the scamp_extensions module might be useful?

The usage is kind of like this:

from scamp import *
from scamp_extensions.playback import MultiPresetInstrument

s = Session()

viola = MultiPresetInstrument(s, "Viola").\
    add_preset("legato", s.new_midi_part("IAC", start_channel=0, num_channels=1)).\
    add_preset("pizz", s.new_midi_part("IAC", start_channel=1,  num_channels=1)).\
    add_preset("staccato", s.new_midi_part("IAC", start_channel=2, num_channels=1)))

viola.play_note(60, 0.7, 1.0)   # defaults to first, legato preset
viola.play_note(62, 0.7, 1.0, "pizz")   # should send to channel 1
viola.play_note(60, 0.7, 1.0, "staccato")   # should send to channel 2

It’s basically a wrapper around several channel-specific instruments that lets you interface with it as though it’s a single instrument.

oh, cool - yes, that is exactly the type of implementation I was looking for. thanks!