[jsyn] MIDI SynthNote
jsyn at music.columbia.edu
jsyn at music.columbia.edu
Wed Jan 24 13:58:52 EST 2007
Hello Ross-c
I think you should turn this upside down; instead of subclassing
SynthNote, create a Java interface called "Instrument" or something,
that defines noteon and noteoff
Your sequencer or whatever it is you are using to bang notes plays
Instrument's instead of something as device-specific as a SynthNote.
So then define MidiPlayableNote and SynthPlayableNote and
OSCPlayableNote, all of which implement Instrument
The Instrument knows which device it is sending to and behaves accordingly.
This is basically how JMSL abstracts Music Devices, and device-specific
Instruments, that allows MIDI to play along with JSyn or whatever other
music device one cares to define...
See...
http://www.algomusic.com/jmsl/docs/com/softsynth/jmsl/MusicDevice.html
(and implementing Midi and JSyn classes)
...and...
http://www.algomusic.com/jmsl/docs/com/softsynth/jmsl/Instrument.html
(and implementing Midi and JSyn classes)
Thanks
Nick Didkovsky
jsyn at music.columbia.edu wrote:
> Hi. I would like to make a SynthNote extending class that sends MIDI
> messages when the noteOn() and noteOff() methods are called.
>
> As far as I can see, the best way of doing this is this ...
>
> First create a MIDI Transmitter.
>
> Call the constructor for my SynthNote, passing the Transmitter as an
> argument.
>
> Override the noteOn() and noteOff() methods to prevent normal behaviour.
> Or, if the strange way that Java handles child classes prevents this
> working when my object is cast to a SynthNote, override the setStage()
> method as per normal.
>
> When a noteOn() (or setStage( time, stage=0 )) event occurs, then take the
> frequency and "reverse engineer" the closest MIDI note number for the
> frequency. Same for the amplitude. In my intended applications, an
> approximation would be fine. If the SynthNote is playing when a noteOn()
> occurs, send a MIDI NoteOff, then a MIDI NoteOn for the new note. I would
> have to remember the MIDI note sent during a noteOn(), but this is
> trivial.
>
> If I want to send polyphonic MIDI data, then I'd need some sort of Voice
> Allocator (I must admit I've only used BussedVoiceAllocator, but there may
> be more appropriate ones), but I don't think that will cause confusion as
> individual SynthNotes will end up representing currently playing MIDI
> notes.
>
> If I did this, then code written to use SynthNotes to play back music
> could then be easily reused to play back music using external MIDI sound
> devices. OSC would then of course be next.
>
> Are there any fundamental problems or "gotchas" with what I describe?
>
> Thanks in anticipation,
>
> Ross-c
>
>
>
> _______________________________________________
> JSyn mailing list
> JSyn at music.columbia.edu
> To change digest mode or to make other administrative changes visit:
> http://music.columbia.edu/mailman/listinfo/jsyn
>
More information about the JSyn
mailing list