[jmsl] Passing MusicShape to PHP

jmsl at music.columbia.edu jmsl at music.columbia.edu
Mon Apr 13 13:06:20 EDT 2009


I wrote a testing program that uploads a file through php. Everything seems 
to work well. I'm having a problem figuring out making MusicShape.save to 
write through DataOutputStream. Nothing gets written. The file just has the 
text "This is a test." that I added at the end. How can I make it work?
Thanks for the help. Here's the code.


MidiInstrument ins = new MidiInstrument(1);
MusicShape s1 = new MusicShape(ins.getDimensionNameSpace() );
s1.add(0.0, 64, 100, 2.0);
s1.add(0.0, 66, 90, 2.5);
s1.add(1.5, 69, 80, 1.5);
s1.add(0.0, 72, 70, 2.5);
s1.add(1.5, 75, 100, 2.0);
s1.setInstrument(ins);
s1.setRepeats(100);
s1.setName("Piano");


MusicShape s2 = new MusicShape(ins.getDimensionNameSpace());
s2.add(0.3333, 72, 70, 0.33);
s2.add(0.3333, 74, 80, 0.33);
s2.add(0.3333, 77, 70, 0.33);
s2.add(0.6666, 80, 85, 0.66);
s2.add(0.3333, 73, 70, 0.33);
s2.setInstrument(ins);
s2.setRepeats(100);
s2.setName("Oboe");


String newLine = "\r\n";
 String dashes = "--";


 URL url = new URL("http://localhost/upload.php");
huc = (HttpURLConnection) url.openConnection();
huc.setDoInput(true);
huc.setDoOutput(true);
   huc.setUseCaches(false);
huc.setRequestMethod("POST");
huc.setRequestProperty("Connection", "Keep-Alive");
huc.setRequestProperty("Content-Type", 
"multipart/form-data;boundary="+boundary);


DataOutputStream dos = new DataOutputStream( huc.getOutputStream());
dos.writeBytes(dashes + boundary + newLine);
dos.writeBytes("Content-Disposition: form-data; name=\"Message\"" + 
newLine);
dos.writeBytes(newLine);
dos.writeBytes(msg + newLine);
dos.writeBytes(dashes + boundary + newLine);
dos.writeBytes("Content-Disposition: form-data; name=\"upload\";" + " 
filename=\"" + fileName +"\"" + newLine);
dos.writeBytes(newLine);
PrintWriter pw = new PrintWriter(dos);
s1.save(pw);
s2.save(pw);


dos.writeBytes("This is a test.");

dos.writeBytes(newLine);
dos.writeBytes(dashes + boundary + dashes + newLine);
dos.flush();
dos.close();

----- 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
> 



More information about the jmsl mailing list