[jmsl] Getting MusicShape from PHP
jmsl at music.columbia.edu
jmsl at music.columbia.edu
Mon Apr 13 17:29:38 EDT 2009
Thanks a lot, that seems to work.
As far as bring them back, how can I use MusicShape.load(); to get it to
work using the xml model you suggested?
I can get the entire xml file to a string using
String input = "";
try {
BufferedReader br = new BufferedReader(new
InputStreamReader(httpUrlConnection.getInputStream()));
String line;
while ((line = br.readLine()) != null)
input += line;
br.close();
}
What does exactly shape.load(br); do? Do I have to point BufferedReader to
right before each musicshape starts and load one shape at a time?
Thanks,
Chi
----- Original Message -----
From: <jmsl at music.columbia.edu>
To: <jmsl at music.columbia.edu>
Sent: Monday, April 13, 2009 2:23 PM
Subject: Re: [jmsl] Passing MusicShape to PHP
> You can use a separate ByteArrayOutputStream to capture the
> MusicShape.save() output, and then write the entire contents of the
> ByteArrayOutputStream to our dataoutputstream.
>
> Something like:
>
> ByteArrayOutputStream bout = new ByteArrayOutputStream();
> PrintWriter out = new PrintWriter(bout);
> try {
> m.save(out);
> } catch (IOException e) {
> e.printStackTrace();
> }
> out.close();
> // bout.close(); // need to close? not sure
> // now the ByteArrayOutputStream has stored the contents of
> everything musicshape wrote to PrintWriter
> System.out.println("bout.toByteArray(), you can write this to a
> data output stream " + bout.toByteArray().length);
> // dos.writeBytes(bout.toByteArray());
>
>
> Thanks,
> Nick Didkovsky
>
> jmsl at music.columbia.edu wrote:
>> 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
>>>
>>
>> _______________________________________________
>> 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