[jmsl] Exporting to Midi
jmsl at music.columbia.edu
jmsl at music.columbia.edu
Tue Apr 14 02:27:39 EDT 2009
That's very cool! How can I write the midi file into DataOutputStream so I
can post it to php?
I don't see any method to write to an OutputStream in JMSL.midi.
Can I somehow redirect JMSL.midi.writeMidiFile()?
Thanks,
chi
----- Original Message -----
From: <jmsl at music.columbia.edu>
To: <jmsl at music.columbia.edu>
Sent: Tuesday, April 14, 2009 12:06 AM
Subject: Re: [jmsl] Exporting to Midi
>I can verify that using the non realtime musicClock works for the purposes
>of playing a collection in hyperspeed mode, and logging to a MIDI file.
>Here is a complete working example. After the Midi init dialog, this will
>run instantly, make no sound, and write a MIDI file to
>logs/testMidiFile2.MID
> The key ideas are:
> 1) turn midi logging on
> 2) turn midi quiet
> 3) use non-real-time clock
> 4) add "stop playable" to the top level composable that will write the
> midi file.
> 4) launch your composable (in this case a musicshape)
> Thanks,
> Nick Didkovsky
>
> package jmsltestsuite;
>
> import java.awt.Frame;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import java.io.IOException;
> import java.net.MalformedURLException;
> import java.net.URL;
>
> import com.didkovsky.portview.PVFrame;
> import com.softsynth.jmsl.*;
> import com.softsynth.jmsl.midi.MidiIO_JavaSound;
> import com.softsynth.jmsl.midi.MidiInstrument;
> import com.softsynth.jmsl.view.MusicShapeEditor;
> import com.softsynth.jmsl.view.PVFrameAdapter;
>
> /**
> * Set JMSL.midi to MidiIO_JavaSound and play some Midi melodies
> *
> * MOD 4/14/09: adding non-real-time example, which plays the MusicShape
> with MIDI logging on, Midi quiet, and non real time music clock
> *
> * @author Nick Didkovsky
> */
>
> public class JavaSoundMidiTest {
>
> public static void main(String args[]) {
>
> boolean NON_REAL_TIME = true;
>
> PVFrame myFrame = new PVFrameAdapter();
>
> MusicDevice dev = MidiIO_JavaSound.instance();
>
> try {
> // in case this machine does not have a soundbank in jre, load
> one from url
> JMSL.setIsApplet(true); // flag to use url if soundbank not
> found. If you know where a
> // soundbank is on your machine, comment this isApplet() line
> out and use the file
> // version instead ((MidiIO_JavaSound)
> dev).setSoundbankFile(File f);
> URL soundbankURL = new
> URL("http://www.algomusic.com/javasound/soundbank.gm");
> ((MidiIO_JavaSound) dev).setSoundbankURL(soundbankURL);
> } catch (MalformedURLException e1) {
> e1.printStackTrace();
> }
>
> dev.edit((Frame) myFrame.getComponent());
> dev.open();
>
> JMSL.clock.setAdvance(0.1);
> MusicShape s = new MusicShape(4);
> s.add(0.5, 64, 100, 2.0);
> s.add(0.5, 66, 90, 2.5);
> s.add(0.25, 69, 80, 1.5);
> s.add(0.25, 72, 70, 0.25);
> s.add(0.25, 75, 100, 2.0);
>
> s.setInstrument(new MidiInstrument(1)); // Midi ins on channel 1
>
> s.setRepeats(10);
>
> if (NON_REAL_TIME) {
> JMSL.clock = new NonRealTimeMusicClock();
> JMSL.midi.setQuiet(true);
> JMSL.midi.setMidiLogging(true);
>
> s.addStopPlayable(new Playable() {
> public double play(double playTime, Composable parent)
> throws InterruptedException {
> JMSL.midi.setMidiLogging(false);
> try {
> JMSL.midi.writeMidiFile("logs/testMidiFile2.MID");
> } catch (IOException e) {
> e.printStackTrace();
> }
> return playTime;
> }
> });
> }
>
> if (!NON_REAL_TIME) {
> MusicShapeEditor se = new MusicShapeEditor();
> se.addMusicShape(s);
>
> myFrame.add(se.getComponent());
> myFrame.pack();
> // f.setSize(320, 200);
> myFrame.addWindowListener(new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> JMSL.midi.close();
> System.exit(0);
> }
> });
> myFrame.setVisible(true);
> }
> s.launch(JMSL.now());
> }
>
> }
>
>
>
> jmsl at music.columbia.edu wrote:
>> try this (untested!)
>> After you turn on midi logging...
>>
>> oldClock = JMSL.clock;
>> JMSL.clock = new NonRealTimeMusicClock();
>> double launchTime = JMSL.now();
>> noteLurker.setLaunchTime(launchTime);
>> col.launch(launchTime);
>>
>> // add a Playable to col's stopplayables, so that you are notified when
>> the col finishes, when that Playable is notifies, do this:
>> JMSL.clock = oldClock;
>>
>> Nick
>> jmsl at music.columbia.edu wrote:
>>> I'm trying to develop both midi (only export for compatibility) as well
>>> as xml (export and import for editing).
>>> Is there way to export the entire sequential collection to midi
>>> (ByteArray), so I can pass it to php in non-realtime, instead of saving
>>> it to file?
>>> Thanks,
>>>
>>> Chi
>>> ----- Original Message ----- From: <jmsl at music.columbia.edu>
>>> To: <jmsl at music.columbia.edu>
>>> Sent: Saturday, April 11, 2009 2:39 PM
>>> Subject: Re: [jmsl] Exporting to Midi
>>>
>>>
>>>> I am not sure what your design intent is...
>>>> Do you want to offer a sequencer in an applet, with the ability to edit
>>>> and save music to the server? Do you want to be able to load music
>>>> from the server back into the sequencer for further editing? If so,
>>>> then don't save it as a midi file, save the hierarchy and data as I
>>>> described earlier.
>>>> Thanks
>>>> Nick
>>>>
>>>>
>>>> jmsl at music.columbia.edu wrote:
>>>>> It's just an alternative to xml. If I go for xml route, I would need
>>>>> to make a player.
>>>>> If I go for midi route, I could just embed midi file inn html, but I
>>>>> need to find out the way to export the entire sequence into midi like
>>>>> MidiLoggerRealTimeTest preferably without the rendering time.
>>>>> Which one do you think is easier? Thanks.
>>>>>
>>>>> Chi
>>>>> ----- Original Message ----- From: <jmsl at music.columbia.edu>
>>>>> To: <jmsl at music.columbia.edu>
>>>>> Sent: Saturday, April 11, 2009 10:41 AM
>>>>> Subject: Re: [jmsl] Exporting to Midi
>>>>>
>>>>>
>>>>>> Is your goal really to create a MidiFile or is this is a
>>>>>> followup/alternative to your previous posting (ie a way to save/load
>>>>>> a piece)?
>>>>>> Thanks
>>>>>> Nick
>>>>>>
>>>>>> jmsl at music.columbia.edu wrote:
>>>>>>> I've checked out the example MidiLoggerNonRealTimeTest from
>>>>>>> jmsltestsuite. Is there way to export all the data from sequential
>>>>>>> collection which contains parallel collections which contains music
>>>>>>> shapes to midi in non-realtime? The example seems to feed one midi
>>>>>>> message at a time to the logger.
>>>>>>> If that's the only way, I'd probably need to figure out which notes
>>>>>>> play at the same time from different music shapes from different
>>>>>>> parallel collections and calculate note on and off time which might
>>>>>>> be too much work. MidiLoggerRealTimeTest sounds very simple, but
>>>>>>> users have to wait to hear the whole thing to render into midi. If
>>>>>>> you have a good solution, please let me know.
>>>>>>> How can I make JMSL to play through an external midi device (not
>>>>>>> soundbank) without MidiShare? I know timing might be sloppy, but can
>>>>>>> I still do it?
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Chi
>>>>>>> _______________________________________________
>>>>>>> jmsl mailing list
>>>>>>> jmsl at music.columbia.edu
>>>>>>> http://music.columbia.edu/mailman/listinfo/jmsl
>>>>>> _______________________________________________
>>>>>> jmsl mailing list
>>>>>> jmsl at music.columbia.edu
>>>>>> http://music.columbia.edu/mailman/listinfo/jmsl
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> jmsl mailing list
>>>>> jmsl at music.columbia.edu
>>>>> http://music.columbia.edu/mailman/listinfo/jmsl
>>>> _______________________________________________
>>>> jmsl mailing list
>>>> jmsl at music.columbia.edu
>>>> http://music.columbia.edu/mailman/listinfo/jmsl
>>>>
>>>
>>> _______________________________________________
>>> jmsl mailing list
>>> jmsl at music.columbia.edu
>>> http://music.columbia.edu/mailman/listinfo/jmsl
>> _______________________________________________
>> jmsl mailing list
>> jmsl at music.columbia.edu
>> http://music.columbia.edu/mailman/listinfo/jmsl
> _______________________________________________
>jmsl mailing list
> jmsl at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/jmsl
>
More information about the jmsl
mailing list