b_readChannel crash WAS [ Re: [sc-users] Multi-voice sound file
to single-voice sound files]
blackrain
blackrain.sc at gmail.com
Sun Jan 7 18:05:44 PST 2007
Hi Josh,
crashes here too. it seems to be \b_readChannel doesnt like DiskIn.
I recall tests with this when the command was added and it worked fine
but to be honest, I dont recall if I used DiskIn at all.
for example, this works:
(
k = OSCresponderNode(s.addr, '/b_info', { arg time, responder, msg;
("bufnum :" + msg[1]).postln;
("frames :" + msg[2]).postln;
("Channels :" + msg[3]).postln;
("SampleRate :" + msg[4]).postln;
}).add;
)
s.sendMsg(\b_allocReadChannel, 0, "sounds/FluteE4.aiff", 0, 0, 1, [\b_query, 0])
z = SynthDef(\test, { arg buffer; Out.ar(0, PlayBuf.ar(1, buffer,
BufRateScale.kr(buffer))) }).play
z.free
s.sendMsg(\b_free, 0)
k.remove
x
On 1/7/07, Joshua Parmenter <josh at realizedsound.net> wrote:
> Sorry, but I was wondering if anyone else can confirm that they have
> the problem I mentioned below a few days ago... or, any ideas for a fix?
>
> If I can get this figured out, I think I'll be able to put together
> methods for splitting and merging SoundFiles in the next day or two...
>
> Thanks,
>
> Josh
>
> On Jan 4, 2007, at 6:46 PM, Joshua Parmenter wrote:
>
> > Hi everyone,
> >
> > I am trying to make a method to SoundFile that will create mono
> > soundfile from a multi-channel file, and taking the NRT DiskIn
> > route... However, \b_readChannel seems to crash the server! You can
> > use your own stereo file, or download the referenced one here:
> >
> > www.realizedsound.net/josh/FluteE4.aiff
> >
> > ... and some sample code:
> >
> > s.boot;
> >
> > SynthDef(\testing, {arg buffer;
> > Out.ar(0, DiskIn.ar(1, buffer))
> > }).load(s);
> >
> > s.sendMsg(\b_alloc, 0, 32768, 1)
> > s.sendMsg(\b_readChannel, 0, "sounds/FluteE4.aiff", 0, 32768, 0, 1,
> > 1);
> > s.sendMsg(\s_new, \testing, 1000, 0, 1, \buffer, 0); // CRASH!!!
> > s.sendMsg(\n_free, 1000);
> > s.sendMsg(\b_close, 0);
> > s.sendMsg(\b_free, 0);
> >
> > Thanks for any help!
> >
> > Josh
> >
> > On Jan 4, 2007, at 3:31 PM, Sciss wrote:
> >
> >> you are right, the buffer copying looks odd. it's a left-over of
> >> my attempt to get /b_write working in "appending" mode (which
> >> seems to be impossible ...). i thought i have to keep the output
> >> file open which means that the "buffer knows the file is open", so
> >> i thought i should use two buffers associated with two sound files
> >> (one for read, one for write (keep this open)). so nevermind,
> >> since it didn't work, you can forget about the different buffers,
> >> just use the same one for reading and writing and delete the .copy
> >> statements ...
> >>
> >> but note that DiskOut also looks at the soundfile "associated"
> >> with the buffer (strange concept after all), so you might get in
> >> another trouble when using DiskOut. the easiest would be to use
> >> the Non-Realtime-Mode (NRT) special audio input file (which
> >> replaces the ADC of your soundcard) to read in the multichannel
> >> interleaved file, then you only need one buffer per DiskOut.
> >>
> >> more confusing? ;o) sorry
> >>
> >> ciao, -sciss-
> >>
> >> Am 04.01.2007 um 22:41 schrieb TomD:
> >>
> >>> Oh sorry I didn't see what you meant, Sciss : you tried something
> >>> with /b_write (which doesn't work) and proposed me to modify a
> >>> part of it (replacing b_write with a DiskOut), because it can't
> >>> work that way, ok.
> >>>
> >>> But before all, one thing I don't understand in your proposal is
> >>> why you copy the content of the buffer (inBuffs) into another
> >>> (outBuffs) and then try to write it to files. Why not copy
> >>> directly the content of "inBuffs" (in which you read chunk by
> >>> chunk the multi-channel file, ok) to files ?
> >>>
> >>> Le 3 janv. 07 à 20:07, TomD a écrit :
> >>>
> >>>> I'm not sure to understand what you mean by
> >>>>> it fails because you cannot write out a file in chunks with
> >>>>> successive /b_write s
> >>>>
> >>>> Anyway iI tried to see what happened without :
> >>>>
> >>>> s.sendMsgSync(c, \b_write, 0, "/Volumes/Beta/sounds SC3/%
> >>>> %.aiff".format(f.path.basename, i));
> >>>>
> >>>> it "crashed" too (I don't know exactly what happens but SC
> >>>> boots off and waits... very long...too long...)
> >>>>
> >>>> But the good new is that your proposal WORKS (and it's great).
> >>>> I'm just starting to analyse what you made, but it works...
> >>>>
> >>>> To all of you (I'm just trying to to see what the crash
> >>>> logged ...) thx
> >>>>
> >>>> Le 2 janv. 07 à 02:27, Sciss a écrit :
> >>>>
> >>>>> here is my attempt with chunking. it fails because you cannot
> >>>>> write out a file in chunks with successive /b_write s. if you'd
> >>>>> exchange them with a DiskOut and write the messages to an NRT
> >>>>> file, it might be working.
> >>>>>
> >>>>> ciao, -sciss-
> >>>>>
> >>>>> s.boot;
> >>>>>
> >>>>> (
> >>>>> var f, idx, inPath, outPathPre, outPathPost, outPaths;
> >>>>>
> >>>>> inPath = "/Volumes/Loomis/Kalligraphie/Papier1.aif";
> >>>>> idx = inPath.findBackwards( "." ) ?? { inPath.size };
> >>>>> outPathPre = inPath.copyFromStart( idx - 1 );
> >>>>> outPathPost = inPath.copyToEnd( idx );
> >>>>>
> >>>>> f = SoundFile.openRead( inPath );
> >>>>> f.close;
> >>>>> ("Audio file '" ++ f.path ++ "'. Length = " ++ f.numFrames ++
> >>>>> " sample frames. "++
> >>>>> "Number of channels = " ++ f.numChannels).postln;
> >>>>>
> >>>>> outPaths = Array.fill( f.numChannels, { arg ch; outPathPre ++
> >>>>> "-" ++ (ch + 1) ++ outPathPost });
> >>>>>
> >>>>> fork {
> >>>>> var inBufs, outBufs, off, chunkLen, bndl;
> >>>>>
> >>>>> inBufs = Buffer.allocConsecutive( f.numChannels, s, min
> >>>>> ( f.numFrames, 32768 ));
> >>>>> outBufs = Buffer.allocConsecutive( f.numChannels, s, min
> >>>>> ( f.numFrames, 32768 ));
> >>>>> s.sync;
> >>>>> off = 0;
> >>>>> bndl = List.new;
> >>>>> while({ off < f.numFrames }, {
> >>>>> chunkLen = min( f.numFrames - off, 32768 );
> >>>>> inBufs.do({ arg buf, ch;
> >>>>> // bndl.add( buf.readChannelMsg( f.path, off, chunkLen,
> >>>>> leaveOpen: true, channels: [ ch ]));
> >>>>> bndl.add([ "/b_readChannel", buf.bufnum, f.path, off,
> >>>>> chunkLen, 0, 1, ch ]);
> >>>>> });
> >>>>> s.listSendBundle( nil, bndl );
> >>>>> s.sync;
> >>>>> bndl.clear;
> >>>>> inBufs.do({ arg buf, ch;
> >>>>> bndl.add( buf.copyMsg( outBufs[ ch ], numSamples: chunkLen ));
> >>>>> });
> >>>>> s.listSendBundle( nil, bndl );
> >>>>> s.sync;
> >>>>> bndl.clear;
> >>>>> // NOTE: leaveOpen: true DOESN'T HELP, THE FILE IS
> >>>>> OVERWRITTEN IN EACH CHUNK
> >>>>> outBufs.do({ arg buf, ch;
> >>>>> bndl.add( buf.writeMsg( outPaths[ ch ], f.headerFormat,
> >>>>> f.sampleFormat, chunkLen, leaveOpen: true ));
> >>>>> });
> >>>>> s.listSendBundle( nil, bndl );
> >>>>> s.sync;
> >>>>> bndl.clear;
> >>>>> off = off + chunkLen;
> >>>>> (((off / f.numFrames) * 100).asInteger.asString ++ "%").postln;
> >>>>> });
> >>>>> inBufs.do({ arg buf; buf.close; buf.free; });
> >>>>> outBufs.do({ arg buf; buf.close; buf.free; });
> >>>>> "Done.".postln;
> >>>>> };
> >>>>> )
> >>>>>
> >>>>>
> >>>>> Am 01.01.2007 um 21:05 schrieb TomD:
> >>>>>
> >>>>>> Yes, and ("Channel % saved\n").postf(i) is better still !
> >>>>>>
> >>>>>> So, after having tested the Routine (last version) with some
> >>>>>> files, it works well only for soundfiles not too big (not a
> >>>>>> matter of number of voices). But with a file of 1 GB (and 22
> >>>>>> channels) it doesn't work anymore and the server quits
> >>>>>> defintitivelly before any "writing" process (allocReadChannel
> >>>>>> doesn't achieve its work).
> >>>>>>
> >>>>>> Does it mean that for those big files the only way will be to
> >>>>>> diskout -> diskin ?
> >>>>>>
> >>>>>> Or will have to pass by File, or UNIX commands ?
> >>>>>>
> >>>>>> Problem seems to be the limitation of buffering...
> >>>>>>
> >>>>>> (Happy new year)
> >>>>>>
> >>>>>> Le 1 janv. 07 à 16:47, James Harkins a écrit :
> >>>>>>
> >>>>>>> You can make a couple of lines prettier by using
> >>>>>>> String:format and :postf --
> >>>>>>>
> >>>>>>> (Keeping in mind that these methods swallow backslashes that
> >>>>>>> would be needed in windows)
> >>>>>>>
> >>>>>>> s.sendMsgSync(c, \b_write, 0, "sounds/%%.aiff".format
> >>>>>>> (f.path.basename, i));
> >>>>>>> ("Channel % saved").postf(i);
> >>>>>>>
> >>>>>>> I really love these methods!!
> >>>>>>> hjh
> >>>>>>>
> >>>>>>>
> >>>>>>> On Dec 31, 2006, at 3:00 PM, Joshua Parmenter wrote:
> >>>>>>>
> >>>>>>>> If you hit the bug... this will work:
> >>>>>>>>
> >>>>>>>> s.boot;
> >>>>>>>>
> >>>>>>>> (
> >>>>>>>> // make this the path to your soundfile... this is a test
> >>>>>>>> file I used with three channels
> >>>>>>>> f = SoundFile.new("sounds/DyneTromBF.aif");
> >>>>>>>> f.openRead;
> >>>>>>>> f.numChannels;
> >>>>>>>> f.close;
> >>>>>>>> f.path;
> >>>>>>>>
> >>>>>>>> c = Condition.new;
> >>>>>>>>
> >>>>>>>> Routine.run({
> >>>>>>>> f.numChannels.do({arg i;
> >>>>>>>> s.sendMsgSync(c, \b_allocReadChannel, 0, f.path, 0, 0, i);
> >>>>>>>> s.sendMsgSync(c, \b_write, 0, "sounds/"++f.path.basename+
> >>>>>>>> +i++".aiff");
> >>>>>>>> ("Channel "++i++" saved").postln;
> >>>>>>>> })
> >>>>>>>> })
> >>>>>>>> )
> >>>>>>>
> >>>>>>> : H. James Harkins
> >>>>>>> : jamshark70 at dewdrop-world.net
> >>>>>>> : http://www.dewdrop-world.net
> >>>>>>> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
> >>>>>>>
> >>>>>>> "Come said the Muse,
> >>>>>>> Sing me a song no poet has yet chanted,
> >>>>>>> Sing me the universal." -- Whitman
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> sc-users mailing list
> >>>>>>> sc-users at create.ucsb.edu
> >>>>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >>>>>>
> >>>>>> _______________________________________________
> >>>>>> sc-users mailing list
> >>>>>> sc-users at create.ucsb.edu
> >>>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >>>>>
> >>>>>
> >>>>> _______________________________________________
> >>>>> sc-users mailing list
> >>>>> sc-users at create.ucsb.edu
> >>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >>>>
> >>>> _______________________________________________
> >>>> sc-users mailing list
> >>>> sc-users at create.ucsb.edu
> >>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >>>
> >>> _______________________________________________
> >>> sc-users mailing list
> >>> sc-users at create.ucsb.edu
> >>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >>
> >>
> >> _______________________________________________
> >> sc-users mailing list
> >> sc-users at create.ucsb.edu
> >> http://www.create.ucsb.edu/mailman/listinfo/sc-users
> >
> > ******************************************
> > Joshua D. Parmenter
> > http://www.realizedsound.net/josh/
> >
> > "Every composer – at all times and in all cases – gives his own
> > interpretation of how modern society is structured: whether
> > actively or passively, consciously or unconsciously, he makes
> > choices in this regard. He may be conservative or he may subject
> > himself to continual renewal; or he may strive for a revolutionary,
> > historical or social palingenesis." - Luigi Nono
> >
> >
>
> ******************************************
> Joshua D. Parmenter
> http://www.realizedsound.net/josh/
>
> "Every composer – at all times and in all cases – gives his own
> interpretation of how modern society is structured: whether actively
> or passively, consciously or unconsciously, he makes choices in this
> regard. He may be conservative or he may subject himself to continual
> renewal; or he may strive for a revolutionary, historical or social
> palingenesis." - Luigi Nono
>
>
>
> _______________________________________________
> sc-users mailing list
> sc-users at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>
More information about the sc-users
mailing list