From: owner-sc-users-digest@lists.io.com (sc-users-digest) To: sc-users-digest@lists.io.com Subject: sc-users-digest V1 #107 Reply-To: sc-users Sender: owner-sc-users-digest@lists.io.com Errors-To: owner-sc-users-digest@lists.io.com Precedence: bulk sc-users-digest Monday, April 10 2000 Volume 01 : Number 107 ---------------------------------------------------------------------- Date: Sat, 8 Apr 2000 23:52:10 +0100 From: rkuivila@mail.wesleyan.edu (Ron Kuivila) Subject: iteration question Hi James, The following code just creates a button that removes itself when clicked. (Inspired by tomonori, I am working on a GUI where chunks can be hidden and revealed in the manner of ProTools.) This works correctly, but breaks the Menubar and command-keys. For example, if you type cmd-W after making the button remove itself, SC crashes. ( var w; w = GUIWindow.new("panel", Rect.newBy(128, 64, 400, 400)); ButtonView.new( w, Rect.newBy(35, 128, 128, 20), "B", 0, 0, 1, 0, 'linear') .action_({ arg b; b.window.views.copy.do({arg v; b.window.remove(v); }); b.window.refresh; }); ) Also, it is necessary to iterate on a copy of the views array (since the remove alters the size and contents of the views array). Is this a bug or a feature? RJK ------------------------------ Date: Sat, 08 Apr 2000 19:15:04 +0100 From: Jem Finer <---@---.---> Subject: vx pocket socket Hello, Not sure what the gadget people use in powerbook slots to get i/o is but I think it's pocket vx or something like that . . . Anyway what I was wondering is seeing as how I think they have both digital and analogue out does that mean you can get 4 channels out at once (stereo digital and stereo analogue) and does the same go for input too ? thanks, Jem ------------------------------ Date: Sat, 08 Apr 2000 18:25:12 -0400 From: michael <---@---.---> Subject: Re: vx pocket socket Jem Finer wrote: > Hello, > > Not sure what the gadget people use in powerbook slots to get i/o is but I > think it's pocket vx or something like that . . . Digigram VXPocket PC Card. http://www.digigram.com/products/VXpocket.html > Anyway what I was wondering is seeing as how I think they have both digital > and analogue out does that mean you can get 4 channels out at once (stereo > digital and stereo analogue) and does the same go for input too ? Sadly, no. Analog output mirrors the digital i/o and you have an either/or w/ regards to the input. Michael - -- http://www.metalbox.com ------------------------------ Date: Sat, 8 Apr 2000 16:00:52 -0700 From: Joachim Gossmann <---@---.---> Subject: Re: g4 ...changing back to OS 8.6? (helped to solve quite a few crash problems with soft and hardware for now on my machine...) jo ------------------------------ Date: Sat, 08 Apr 2000 19:47:53 -0400 From: "Anthony G. Holland" <---@---.---> Subject: ibook Does anyone think SC would run on an ibook? Maybe the new 366 MHS ibook? I'm thinking of purchasing an ibook and being able to run sc on it would be a bonus in my view. A. Holland ------------------------------ Date: Sat, 08 Apr 2000 21:54:00 -0500 From: James McCartney <---@---.---> Subject: Re: midi to cps on 4/8/00 12:47 PM, jr@xs4all.nl at jr@xs4all.nl wrote: > two simple questiongs > 1) > Am I wrong to expect that 60.midiratio = 1.0? > > In a patch using Playbuf, passing the playback rate set effectively by > > pbRate=60.midiratio > > results in exactly four times unity playback rate? midiratio is a measure of interval, not absolute pitch. 0.midiratio returns 1.0 12.midiratio returns 2.0 - -12.midiratio returns 0.5 > > 2) > this came up when trying to see what was going on above > If 'note' is defined eg as in example 4 > > patternList = #[55,60,63,62,60,67,63,58]; > note = Sequencer.kr( `patternList, trigger ); > freq = note.midicps; > > Why cant I force this simple function to evaluate itself and display > momentary values > say via > Synth.trepeat(0,0.50) > {... > note.value.postln; > freq.value.postln; > ..} > all I can get out > "an UnaryOpUgen" or "a Sequence" Use .poll not .value .value returns what the object evaluates to - which is an Object. Unit generators are objects. They are not their signal values. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Sat, 08 Apr 2000 21:56:49 -0500 From: James McCartney <---@---.---> Subject: Re: iteration question on 4/8/00 5:52 PM, Ron Kuivila at rkuivila@mail.wesleyan.edu wrote: > Also, it is necessary to iterate on a copy of the views array > (since the remove alters the size and contents of the views array). > Is this a bug or a feature? This is just basic sane programming. _Never_ alter a collection you are iterating over. This is a general rule of thumb for any programming language. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Sun, 09 Apr 2000 17:39:03 +0200 From: Julian Rohrhuber <---@---.---> Subject: Re: iteration question extra James McCartney wrote: > This is just basic sane programming. _Never_ alter a collection you are > iterating over. This is a general rule of thumb for any programming > language. if I have two functions that independently process values in a global array, how would I achieve the same effect by not altering the collection? ------------------------------ Date: Sun, 09 Apr 2000 17:40:20 +0200 From: Julian Rohrhuber <---@---.---> Subject: Array in Array in Array is it very much slower to index into an Arrays of Arrays of Arrays than to write the values into one array and calculate around with the indices? Julian ------------------------------ Date: Sun, 09 Apr 2000 16:03:00 -0500 From: James McCartney <---@---.---> Subject: Re: Array in Array in Array on 4/9/00 10:40 AM, Julian Rohrhuber at sa6a014@rrz.uni-hamburg.de wrote: > is it very much slower to index into an Arrays of Arrays of Arrays > than to write the values into one array and calculate around with the indices? It is probably faster in SC to use Array of Arrays. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Sun, 09 Apr 2000 16:19:52 -0500 From: James McCartney <---@---.---> Subject: Re: iteration question extra on 4/9/00 10:39 AM, Julian Rohrhuber at sa6a014@rrz.uni-hamburg.de wrote: > James McCartney wrote: > >> This is just basic sane programming. _Never_ alter a collection you are >> iterating over. This is a general rule of thumb for any programming >> language. > > if I have two functions that independently process values in a global > array, how would I achieve the same effect by not altering the collection? > You can process the values contained in a collection, no problem, but in general it is not a good idea to add/remove/reorder a collection that you are iterating over. You corrupt your iteration. This is not specific to SuperCollider, this is just basic programming and is as true in C or LISP. If you iterate over a copy of a collection, then you can alter the original and it will not affect your iteration. Or in even better style you return a new altered collection by iterating over the original. This is pure functional programming style. Pure functional programming languages are those that do not allow any data to be altered, only new data created. This has a lot of good properties - but it is a rather deep subject for here. Pure functional languages, since they never can have side effects (alter data), can be automatically parallelized at any level of granularity. Pure functional code can also be more easily decomposed and recomposed because of the lack of side effects. Knowledge of pure functional programming techniques are useful and can be employed in impure functional languages like SuperCollider. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Mon, 10 Apr 2000 00:40:13 EDT From: DSPGuy@aol.com Subject: System 9.0.4 allows input from PB CD I have been using a PowerBook Wallstreet with System 9.0. System 9.0 doesn't let you select the CD player in the expansion bay as the input source. I discovered this when I was wanting to use a CD as a signal source for a SC program; others on the list were familiar with this problem. (It may not be limited to PowerBooks, and is not an SC problem.) I have just installed the new system update, 9.0.4, and am delighted to find that the CD can now be used as a source. SC sees it immediately, and I can also record from the CD to disk (I tried Peak 2.10 for this). The Sound control panel and the input selector control strip module look like they did before 9.0, without a separate section for "CD" input, and with the selection for "Expansion Bay" back in. Thought some of you would benefit from this info. Jerry ------------------------------ Date: Mon, 10 Apr 2000 16:45:04 +0200 From: Julian Rohrhuber <---@---.---> Subject: Re: iteration question extra > You can process the values contained in a collection, no problem, but in > general it is not a good idea to add/remove/reorder a collection that you > are iterating over. You corrupt your iteration. //______bad style ? ( i = 0; a = Array.fill(16, { #[1, 0].choose }); { arg synth; p = Plug.kr(0, 0.2); synth.repeat(0.01, 0.01, { if( 0.5.coin, { a = a.add(#[1, 0].choose) }, { a.remove(#[1, 0].choose) }) }); Task.new({ loop({ i = i+1; p.source = a.wrapAt(i); 0.01.wait; }) }); SinOsc.ar(500, 0, p/10) }.play; ) //______good style ? ( i = 0; a = Array.fill(16, { #[1, 0].choose }); b = a; { arg synth; p = Plug.kr(0, 0.2); synth.repeat(0.01, 0.01, { if( 0.5.coin, { a = a.add(#[1, 0].choose) }, { a.remove(#[1, 0].choose) }) }); Task.new({ loop({ i = i + 1; if ( i%16 == 0, { b = a }); p.source = b.wrapAt(i); 0.01.wait; }) }); SinOsc.ar(500, 0, p/10) }.play; ) >This is not specific to > SuperCollider, this is just basic programming and is as true in C or LISP. > If you iterate over a copy of a collection, then you can alter the original > and it will not affect your iteration. Or in even better style you return a > new altered collection by iterating over the original. This is pure > functional programming style. > Pure functional programming languages are those that do not allow any data > to be altered, only new data created. This has a lot of good properties - > but it is a rather deep subject for here. Pure functional languages, since > they never can have side effects (alter data), can be automatically > parallelized at any level of granularity. Pure functional code can also be > more easily decomposed and recomposed because of the lack of side effects. > Knowledge of pure functional programming techniques are useful and can be > employed in impure functional languages like SuperCollider. ------------------------------ Date: Mon, 10 Apr 2000 12:37:53 -0500 From: James McCartney <---@---.---> Subject: Re: iteration question extra on 4/10/00 9:45 AM, Julian Rohrhuber at sa6a014@rrz.uni-hamburg.de wrote: > b = a; This does not make a copy. Both a and b now point to the same array. You are still iterating over the collection you are changing. To make a copy you should write: b = a.copy; However in either example what you are doing looks OK since wrapAt will insure that you never index out of bounds. The problems come when you are trying to do something like remove items from a list and you remove them from the list you are iterating over. In this case you should return a new list without those items. If you use the Collection 'reject' method, then that is what it does. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Mon, 10 Apr 2000 18:25:48 -0600 From: Jim Coker <---@---.---> Subject: Woody Vasulka digs Supercollider Got to demo it for him and his coworker Bruce Hamilton this past Saturday in Santa Fe. Woody and his wife Steina are two of the first to do video art, you can find more about them at: http://www.artscilab.com/main.html He especially liked the pitch shifter and the built-in multi-channel capabilities. Jim ------------------------------ End of sc-users-digest V1 #107 ******************************