From: owner-sc-users-digest@lists.io.com (sc-users-digest) To: sc-users-digest@lists.io.com Subject: sc-users-digest V1 #3 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 Thursday, July 23 1998 Volume 01 : Number 003 ---------------------------------------------------------------------- Date: Wed, 8 Jul 1998 23:22:58 -0700 From: James McCartney <---@---.---> Subject: Re: Example of scheduling events from a score file in SC 1.x At 9:48 PM -0700 7/8/98, Philip Galanter wrote: >In my version there is always a minimum of 250 events in the queue...its >always kept at least half full, so closely spaced events in reasonable >numbers will always be already scheduled and ready to go. > >I guess this boils down to a question as to how SC divides its time among >tasks. >I assumed that the scheduler would have a priority second only to the DSP >engine, and would spawn multiple tasks timesharing at a third priority. >This way a long running routine scheduling events for the "distant future" >wouldn't get in the way of starting or executing near term events. > The MacOS does not have any form of prioritized time slicing and the sound interrupt is a pretty crude environment. Besides I had certain design goals that conflicted with asynchronous scheduling. There are no priorities. It does not divide its time. It does everything in a linear order. Synthesis and scheduling happen in the same interrupt. SC is a tightly coupled (synchronous synthesis and scheduling/control) system as opposed to a loosely coupled system (asynchronous). The advantage is that you can run high level code within the audio stream rather than just scheduling things. Something like the Sequencer object in SC2 which can execute any high level code to produce its output would not be possible in a loosely coupled system without some sort of lag. The disadvantage is that you cannot spend lots of time doing any one thing. >It sounds like that was a bad assumption. Are you saying that when the >scheduler starts event N (and calls the corresponding function), it will >not be able to start event N+1 until N completes? All code is executed in order, yes. >Also, regarding the time it takes to build a synth voice. Can this be so >great that a mix of very simple and very complex patches will result in >audible timing jitter? If so, is there a way to measure this and then >tweak the starting times when scheduling to compensate for this? Yes. Only by monitoring CPU usage. There are certainly drawbacks to the tight coupling, but my goal was to be able to run high level code synchronously in response to signal level events. With an asynchronous scheduler this would not be possible. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Thu, 09 Jul 1998 15:40:25 -0500 From: Philip Galanter <---@---.---> Subject: Re: Example of scheduling events from a score file in SC 1.x James, thanks!. That little peek under the hood, combined with a better understanding of your design goals, really helps. cheers, Phil =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Philip Galanter New York University phone: 212-998-3041 Associate Director 251 Mercer fax: 212-995-4120 for Arts Technology New York, NY 10012 internet: galanter@nyu.edu N Y U A c a d e m i c C o m p u t i n g F a c i l i t y Info, resources, art gallery, and more... http://www.nyu.edu/atg/ ------------------------------ Date: Fri, 10 Jul 1998 18:17:10 -0400 (EDT) From: David Crandall <---@---.---> Subject: Korg 1212 in a MAGMA expander box? Apologies for duplicate postss... I recently asked about soundcards that will work with various programs (SC, MSP, etc.). The Korg 1212 seems to have been the hands-down winner, except that Digidesign still doesn't (AFAIK) talk to it (yes, we know it darn well should). I also asked about any of this in connetion with a G3 Powerbook. I just saw an old email about the MAGMA PCI expander box for the G3 and wonder: is anyone using this combination? Another question that came up is about Studio Vision and the 1212; material I've seen says that they work together "via Sound Manager." What are the limitations of this? TIA, dc ------------------------------ Date: Sun, 12 Jul 1998 03:11:43 -0700 From: James McCartney <---@---.---> Subject: Re: SC2d18 FYI: I fixed the AIFF loop end problem. The fix did not make it in to the upload that I made this afternoon (SC2d20). It will be in SC2d21. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Sun, 12 Jul 1998 03:56:18 -0700 From: James McCartney <---@---.---> Subject: SC2d20 now available. A new version is available from: ftp://www.audiosynth.com//pub/updates/SC2d20.sea.hqx There is also a slightly older version SC2d19 which has tentative support for the Korg1212 (SC2d20 does not) for those who have one and wish to test it. ftp://www.audiosynth.com//pub/updates/SC2d19.sea.hqx New in d20: Has a serial number form of authorization. Registered users may send me an email to get a serial number to unlock the program for full functionality. That will be your own private serial number. Do not give it out. The serial number will expire in 6 months at which time you will need to get a new one. When further updates are released that same serial number will work for those as well. There is no key disk or locking to a particular hard drive. Spawn has been reworked to have a better timing model. You can either specify the next time for an event as before or set next time to nil which will have spawn determine the next time from the logical duration of the spawned event. THe only sub events that have a logical duration are those which themselves have a Spawn object. (Setting next time to nil used to stop scheduling in previous versions. In order to stop scheduling in a Spawn, you now call the stop method.) What this lets you do is to create nested structures that progress when their subevents finish. There is a demo file called 'timing structures' that demonstrates this. The documentation for the new classes based on Spawn and on how both logical and physical durations work will be forthcoming. There is a new class Pause which will pause a process if the amplitude gate input drops to zero or below. There is a new external control source MIDINoteGate which switches on and off if a particular MIDI note is on or off. There is a new language feature based on the Environment class which allows the definition of environment variables which are dynamically bound variables that are looked up in a cascading hierarchy. Environments act like IdentityDictionaries which have a parent. If a value for a variable is not found in the current environment, it is looked up in the parent. In this way you can override the value of a particular name. Environment variables are denoted by preceeding the variable name with a ~ which is no longer a binary operator char. Environment variables will allow the specification of general values for many compositional parameters like keynote, scale, degree, amplitude, duration, instrument, etc.. which may be overridden at more specific lower levels of the composition. Environments have been unified with the events that PatternStreams return. The pattern example has been changed so that it uses environment variables. All of this is not documented yet, so I know that you all probably don't have much of a clue what I'm talking about.. bear with me. There is some more documentation, but not on the newest features. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Sun, 12 Jul 1998 08:55:19 -0700 From: James McCartney <---@---.---> Subject: send serial number reqs to support@audiosynth.com Please send serial number requests to support@audiosynth.com. This will insure your request does not get lost in my omnivorous spam eating james@clyde.as.utexas.edu account. Those of you who've already sent to james@clyde.as.utexas.edu don't need to send again though. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Tue, 14 Jul 1998 22:05:38 +0200 From: laurson@siba.fi (Mikael Laurson) Subject: OrcScore My question concerns the "an orchestra and score player" example. I would like to use OrcScore so that I could read either the orchestra or the score part of the code from a text-file (this file would be typically created outside SC). I was able to read a text-file into SC using the method readAllString. The problem is that readAllString returns the data as a string and not as an array. Is there a primitive in SC2 that can convert a string to an array? (In SC1 I used a function called freadlist to perform a similar task.) Also I would like to be able store the results to a file (like the "out to file" option in SC1) Is this already possible? Mikael ================================ Mikael Laurson Hollantilaisentie 1 A 2 00300 Helsinki 33 Finland E-mail: laurson@siba.fi ================================ ------------------------------ Date: Tue, 14 Jul 1998 14:59:23 -0700 From: James McCartney <---@---.---> Subject: Re: OrcScore At 1:05 PM -0700 7/14/98, Mikael Laurson wrote: >My question concerns the "an orchestra and score player" example. >I would like to use OrcScore so that I could read either the orchestra or the >score part of the code from a text-file (this file would be typically >created outside SC). >I was able to read a text-file into SC using the method readAllString. The >problem is >that readAllString returns the data as a string and not as an array. Is >there a primitive in SC2 >that can convert a string to an array? (In SC1 I used a function called >freadlist to perform a similar >task.) There is not yet a parsing primitive for text. However the recommended way to load in your score is as code. This allows you to put any legal SC expression into your score. If you generate your score as a legal SuperCollider expression such as : - --- begin file --- [ [0.1, 0, 64, 0.3], [0.2, 0, 67, 0.3] ] - --- end file --- Then you can read it like this: myscore = thisProcess.interpreter.executeFile("myFolder:myfilename"); You can use this technique to compile and execute any file at run time. You should do this before you call Synth.play, i.e. don't put executeFile inside of a Spawn event function. >Also I would like to be able store the results to a file (like the "out to >file" option in SC1) Is this already possible? This is not yet done. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Wed, 15 Jul 1998 15:41:19 -0700 From: James McCartney <---@---.---> Subject: Re: OrcScore > >>Also I would like to be able store the results to a file (like the "out to >>file" option in SC1) Is this already possible? > >This is not yet done. > I should qualify this. You CAN write to a file, just not in real time yet. Use Synth.write(). See the Synth help file. --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Wed, 15 Jul 1998 17:39:03 -0700 From: James McCartney <---@---.---> Subject: SC2d21 Now with FFT SC2d21 is now available at : ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx The FFT and IFFT UGens now work. See the example file "FFT examples". --- james mccartney james@clyde.as.utexas.edu james@lcsaudio.com If you have a PowerMac check out SuperCollider, a real time synth program: http://www.audiosynth.com ------------------------------ Date: Thu, 16 Jul 1998 19:21:48 +0200 From: Ioannis Zannos <---@---.---> Subject: Using LFSaw as amplitude control. Hi, Actually I would expect a saw oscillator passed as generator for the multiply (mul) parameter of another generator to produce a repeating crescendo i.e. repeating swelling tone. What I got in the examples below was either a smooth wavy swell - - corresponding to a triangle rather than a saw, or a swell with a "pop" like jump in the middle. Whats wrong? Synth.play(SinOsc.ar(800, 0, LFSaw.kr(0.25, 0.5, 0))); Synth.play(Saw.ar(500, Saw.ar(2, 0.5, 0), 0)); Synth.play(Saw.ar(500, LFSaw.kr(2, 0.5, 0), 0)); Synth.play(LFSaw.ar(LFSaw.kr(2, 400, 400), LFSaw.kr(0.25, 0.5, 0))); ========================================== Iannis ========================================== Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ Date: Thu, 16 Jul 1998 13:03:50 -0700 From: James McCartney <---@---.---> Subject: Re: Using LFSaw as amplitude control. At 10:21 AM -0700 7/16/98, Ioannis Zannos wrote: >Hi, > >Actually I would expect a saw oscillator passed as >generator for the multiply (mul) parameter of another >generator to produce a repeating crescendo >i.e. repeating swelling tone. > >What I got in the examples below was >either a smooth wavy swell >- corresponding to a triangle rather than a saw, >or a swell with a "pop" like jump in the middle. > >Whats wrong? > >Synth.play(SinOsc.ar(800, 0, LFSaw.kr(0.25, 0.5, 0))); The sawtooth goes from -1 to +1, so the amplitude goes from -1 to zero to +1 then instantaneously inverts to -1, hence the pop. So you need to offset the saw to be all positive: LFSaw.kr(0.25, 0.5, 0.5) Now it will go from zero to one and then drop instantly back to zero. If you have questions like these about what is going on, then use Synth.plot() or Synth.scope() to look at your output. --- james mccartney james@audiosynth.com http://www.audiosynth.com If you have a PowerMac check out SuperCollider2, a real time synth program: ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx ------------------------------ Date: Thu, 16 Jul 1998 20:04:34 +0100 From: finer@easynet.co.uk Subject: GUI In the GUI documentation it says : Edit GUI Toggles the GUI window to/from Edit mode. In Edit mode you can add and remove Views, move Views around, and edit their characteristics. I can't find the little trick to enable me to "edit their characteristics" - - the thing that was command - I in SC1. Or does one do this now all in code ? Thanks, Jem Finer Kentish Town London NW5 finer@easynet.co.uk 44 171 267 6416 ------------------------------ Date: Thu, 16 Jul 1998 14:45:28 -0700 From: James McCartney <---@---.---> Subject: Re: GUI At 12:04 PM -0700 7/16/98, finer@easynet.co.uk wrote: >In the GUI documentation it says : > >Edit GUI > >Toggles the GUI window to/from Edit mode. In Edit mode you can add and >remove Views, >move Views around, and edit their characteristics. > >I can't find the little trick to enable me to "edit their characteristics" >- the thing that was command - I in SC1. Select the item, then press return. --- james mccartney james@audiosynth.com http://www.audiosynth.com If you have a PowerMac check out SuperCollider2, a real time synth program: ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx ------------------------------ Date: Fri, 17 Jul 1998 10:21:37 +0200 From: Ioannis Zannos <---@---.---> Subject: Re: Using LFSaw as amplitude control. At 1:03 PM -0700 16.7.1998, James McCartney wrote: >At 10:21 AM -0700 7/16/98, Ioannis Zannos wrote: > >The sawtooth goes from -1 to +1, so the amplitude goes from -1 to zero >to +1 then instantaneously inverts to -1, hence the pop. So you >need to offset the saw to be all positive: > >LFSaw.kr(0.25, 0.5, 0.5) > >Now it will go from zero to one and then drop instantly back to zero. > >If you have questions like these about what is going on, then use >Synth.plot() or Synth.scope() to look at your output. Thanks. I am aware of Synth.plot(), but have not tried it out on kr methods - my mistake. Yet, perhaps it is worth mentioning the default value ranges that apparently apply to several groups of UGens, or even better to mention the default ranges for each UGen. (I checked the Help files as far as I could - found no info). Also something I missed since the beginning of SC was an explanation of the algorithms behind each UGen. I have started writing up some for my own reference, perhaps they could incorporated in the help files some day... Cheers, Iannis =================================================== Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ Date: Fri, 17 Jul 1998 14:58:18 +0200 From: laurson@siba.fi (Mikael Laurson) Subject: SoundFile in SC2d21 The read method of SoundFile (SC2d21) returns as a side effect some debugging info when I try to read Aiff files. This does not happen when reading SDII files. For instance when reading a Aiff file called "normd" this results in the following: ( // normal playback at same speed of recording var filename, sound, signal; filename = ":Sounds:normd"; sound = SoundFile.new; if (sound.read(filename), { signal = sound.data.at(0); Synth.play(Samp.ar(signal, sound.sampleRate, 1, 0, 0, signal.size-2)); },{ (filename ++ " not found.\n").post }); size 34 0 77 'M' 1 65 'A' 2 82 'R' 3 75 'K' 4 0 '.' 5 0 '.' 6 0 '.' 7 34 '"' etc. Mikael ================================ Mikael Laurson Hollantilaisentie 1 A 2 00300 Helsinki 33 Finland E-mail: laurson@siba.fi ================================ ------------------------------ Date: Fri, 17 Jul 1998 08:59:01 -0700 From: James McCartney <---@---.---> Subject: Re: Using LFSaw as amplitude control. At 1:21 AM -0700 7/17/98, Ioannis Zannos wrote: >At 1:03 PM -0700 16.7.1998, James McCartney wrote: >>At 10:21 AM -0700 7/16/98, Ioannis Zannos wrote: > >> >>The sawtooth goes from -1 to +1, so the amplitude goes from -1 to zero >>to +1 then instantaneously inverts to -1, hence the pop. So you >>need to offset the saw to be all positive: >> >>LFSaw.kr(0.25, 0.5, 0.5) >> >>Now it will go from zero to one and then drop instantly back to zero. >> >>If you have questions like these about what is going on, then use >>Synth.plot() or Synth.scope() to look at your output. > >Thanks. I am aware of Synth.plot(), but have not tried >it out on kr methods - my mistake. Well you can't plot kr ugens directly, you need to wrap them in K2A.ar(LFSaw.kr(0.25, 0.5, 0.5)) in order to convert them to audio rate. > >Yet, perhaps it is worth mentioning the default value ranges >that apparently apply to several groups of UGens, or even >better to mention the default ranges for each UGen. >(I checked the Help files as far as I could - found no info). Oscillators are -1 to +1 unless otherwise noted. COsc and COsc2 go from -2 to +2. LFPulse goes from 0 to 1. > >Also something I missed since the beginning of SC >was an explanation of the algorithms behind each UGen. >I have started writing up some for my own reference, >perhaps they could incorporated in the help files some day... Some of the algorithms are trade secrets. My Osc oscillators are faster than any other implementation I know of. I get as many oscillators on my 3400 603e as MSP reports getting on a G3. --- james mccartney james@audiosynth.com http://www.audiosynth.com If you have a PowerMac check out SuperCollider2, a real time synth program: ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx ------------------------------ Date: Fri, 17 Jul 1998 09:00:38 -0700 From: James McCartney <---@---.---> Subject: Re: SoundFile in SC2d21 At 5:58 AM -0700 7/17/98, Mikael Laurson wrote: >The read method of SoundFile (SC2d21) returns as a side effect >some debugging info when I try to read Aiff files. This >does not happen when reading SDII files. >For instance when reading a Aiff file called "normd" this >results in the following: oops, sorry! Thanks! I'll remove it. Hopefully at least the loop point is correct now? --- james mccartney james@audiosynth.com http://www.audiosynth.com If you have a PowerMac check out SuperCollider2, a real time synth program: ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx ------------------------------ Date: Fri, 17 Jul 1998 17:11:23 +0200 From: Ioannis Zannos <---@---.---> Subject: Re: Using LFSaw as amplitude control. At 8:59 AM -0700 17.7.1998, James McCartney wrote: >Some of the algorithms are trade secrets. My Osc oscillators are faster >than any other implementation I know of. I get as many oscillators on >my 3400 603e as MSP reports getting on a G3. > I don't mean the algorithms used for optimized implementation, I mean the mathematic principle on which the sound effect or the oscillator is based. Most of these should be well known, but its useful to give their formula as a simple mathematical expression, for reference. As regards performance, it would be interesting to benchmark some patches in the two systems SC / MSP and compare them on the same machine... Iannis ========================================= Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ Date: Fri, 17 Jul 1998 16:11:54 -0600 From: antiorp@tezcat.com (=cw4t7abs) Subject: Re: Using LFSaw as amplitude control. >As regards performance, it would be interesting to >benchmark some patches in the two systems SC / MSP >and compare them on the same machine... reazon =_? sc != msp msp != sc ------------------------------ Date: Sat, 18 Jul 1998 01:11:08 -0700 From: James McCartney <---@---.---> Subject: SC2d22.sea.hqx Yet another version. ftp://www.audiosynth.com//pub/updates/SC2d22.sea.hqx I will be going out of town tomorrow until Aug 1, so I wanted to get this out before I leave. I will still be reading email. The Voicer class now works. This UGen is a subclass of Spawn which allocates voices in response to MIDI keys. It responds to sustain and sostenuto pedals, all notes off, and has a smart voice stealing algorithm when the maximum voices are exceeded. There is a file called "Voicer example" that has a brief example of it. Some of the Spawn.help examples had to be changed. Spawn now restores the original values of nextTime, blockSize, channelOffset before calling each new event. This allows multiple instruments to make their own settings per event and not step on each other. But it means that events can't do things like sp.nextTime = sp.nextTime * 1.05; as was being done in the Spawn examples. So a separate variable is needed for those examples. The debug prints are removed from SoundFile reading. A number of other bug fixes, doc fixes and example tweaks were also made. --- james mccartney james@audiosynth.com http://www.audiosynth.com If you have a PowerMac check out SuperCollider2, a real time synth program: ftp://www.audiosynth.com//pub/updates/SC2d21.sea.hqx ------------------------------ Date: Tue, 21 Jul 1998 21:40:36 +0100 From: finer@easynet.co.uk Subject: Instance methods v. class methods Taking for example the CLASS, Synth : It has methods preceded by an * which according to the documentation are "class methods". eg *play { arg inUgenGraph, inDuration, inBlockSize, inReleaseTime; ^this.new(inUgenGraph, inBlockSize, 0, inReleaseTime).play(inDuration)} and it has methods not preceded by * which, by default, I assume then are "instance methods". eg play { arg inDuration; _SynthPlay ^this.primitiveFailed } I'm a bit confused ! If I write Synth.play I assume that the method *play is called (or should I say the message *play is sent to the class Synth ?) - - so why and what about play ? Furthermore re the underscore before SynthPlay, ie _SynthPlay. Is this then a setter message ? Setting what ? Sorry - probably makes no great differance to working with SC2 but I'd really like to figure this o.o.p. buisness out for once and for all ! Thanks, Jem Finer Kentish Town London NW5 finer@easynet.co.uk 44 171 267 6416 ------------------------------ Date: Tue, 21 Jul 1998 16:51:54 -0700 (PDT) From: James McCartney <---@---.---> Subject: Re: Instance methods v. class methods At Tue Jul 21 21:40:36 1998, wrote: >Taking for example the CLASS, Synth : > >It has methods preceded by an * which according to the documentation are >"class methods". > >eg *play { arg inUgenGraph, inDuration, inBlockSize, inReleaseTime; > ^this.new(inUgenGraph, inBlockSize, 0, >inReleaseTime).play(inDuration)} > >and it has methods not preceded by * which, by default, I assume then are >"instance methods". > >eg play { arg inDuration; > _SynthPlay > ^this.primitiveFailed } > >I'm a bit confused ! If I write Synth.play I assume that the method *play >is called (or should I say the message *play is sent to the class Synth ?) >- so why and what about play ? Synth.play(..) // calls the class method *play. // the receiver is the Synth class object. var myvar; .. myvar = Synth.new(..); // creates an instance of Synth myvar.play; // calls the instance method play. // the receiver is an instance of Synth. > >Furthermore re the underscore before SynthPlay, ie _SynthPlay. Is this then >a setter message ? Primitive names are preceeded by an underscore. Setter names have a trailing underscore. _SynthPlay is a C primitive function that implements the method. In other words it is a magic black box. ------------------------------ Date: Wed, 22 Jul 1998 12:30:45 +0200 From: Ioannis Zannos <---@---.---> Subject: Spawn example bugs; various questions Hello, the first two examples from the newest Spawn.help file keep freezing on my 604/200 PPC for no understandable reason. The second example (...FSinOsc.ar(2000.0.rand, EnvGen.kr(e)),...) crashes especially when I stop it with command-. It will keep playing, but the mac freezes. And some other questions or remarks - I hope it is OK to post them directly here. - - What are ~, <, >, <> What is the meaning of the followintg prefixes: ~, <, >, <> to variables? I assume ~ means "get the value of the variable from the actual environment". But it is not clear how the environment mechanism functions and what it is good for - assume again a scheme similar to tempo base of SC1.f and pyrite, but more general, applying to other values also (frequency etc.). The multitude of pattern, stream and environment subclasses suggests something fascinating has happened there like with the UGens, but there is no doc about it yet. I am studying the pat examples, but it's slow work. - - When does one use ^ to return - when not? Is there a particular reason for doing away with ^ as return operator in class methods, but retaining it in function closures (blocks?) - - How to trigger patterns and/or sounds from GUI items? For example, how to realise the same thing as following SC1.x program, where the check-box gui items 1 and 2 are connected to "LowAndSlow" and "HighAndFast" respectively?: - --------------------------------- defaudioout L R; init { } start { } ping { arg freq = 400, dur = 1, amp = 0.3; var env osc; env = Aparenv(dur, amp, `dspRemove); osc = Asinosca(freq, 0, 0); { osc.(freq, 0, env.).out([L R]); }.dspAdd; } keepPinging { arg item = 1, freq = 300, dur = 1; { if item.getItemValue > 0 then ping(freq, dur); [dur, thisFunc].sched; else [item 'stopped'].post; end.if; }.value } LowAndSlow { keepPinging; } HighAndFast { keepPinging(2, 900, 2/5); } - --------------------------------- Yours, Iannis ========= Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ Date: Wed, 22 Jul 1998 12:46:43 +0200 From: Ioannis Zannos <---@---.---> Subject: Scheduling with spawn, without sound, reacting to input. Spawn and patterns again, rephrasing and completing my previous post about the GUI - scheduling question: In SC 1.x one used to go { .... [dur, thisFunc].sched; } and the defined closure could be started at any time. Moreover it did not require a UGen graph to be involved (no dspAdd, no Oscillators or similar stuff was required), in order for scheduling to work. The current framework of SC 2 most encountered in examples goes like: Synth.play( Spawn.ar( { ... Since according to the doc, Spawn requires a UGen graph to be returned from the newEventFunc argument, how does one start recurringly executed computations like polling/ displaying the mouse position at regular intervals, processing input or internal states with neural networks or rule systems etc., when all these do not involve any sound output? Furthermore, how can one make the evaluation of something (e.g. start of a sound or of a computation process) depending on input from the user/environment? (See also my last example about starting from GUI items) Best, Iannis Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ Date: Wed, 22 Jul 1998 09:46:55 -0700 (PDT) From: James McCartney <---@---.---> Subject: Re: Scheduling with spawn, without sound, reacting to input. At Wed Jul 22 12:46:43 1998, Ioannis Zannos wrote: > >Spawn and patterns again, rephrasing and completing >my previous post about the GUI - scheduling question: > >In SC 1.x one used to go > >{ .... > [dur, thisFunc].sched; >} > >and the defined closure could be started at any time. >Moreover it did not require a UGen graph to be involved >(no dspAdd, no Oscillators or similar stuff was required), >in order for scheduling to work. > >The current framework of SC 2 most encountered in examples >goes like: > >Synth.play( > Spawn.ar( { ... > >Since according to the doc, Spawn requires a UGen graph >to be returned from the newEventFunc argument, how does >one start recurringly executed computations like polling/ >displaying the mouse position at regular intervals, >processing input or internal states with neural networks or >rule systems etc., when all these do not involve any sound >output? > >Furthermore, how can one make the evaluation of something >(e.g. start of a sound or of a computation process) >depending on input from the user/environment? >(See also my last example about starting from GUI items) You do not have to return a ugen graph, you can return nil. Scheduling can be done in several ways. You can use the Spawn event function. You can use a Synth task (not yet documented, but the "z analog variant" example uses one). You can execute a block in the Sequencer object upon receiving a trigger from something like a ControlIn which can be linked to a GUI item or MIDI key. There will also be ways of starting an event in a Spawn externally, but that is not done yet. It is not possible to implement sched in the same way for SC2 because computations do not happen exactly in sync. Due to the sample accurate start times, each voice's buffer is shifted in time with the others. So there are multiple time streams not just one. That is why you have Synth tasks scheduled per synth. ------------------------------ Date: Wed, 22 Jul 1998 13:31:37 -0700 (PDT) From: James McCartney <---@---.---> Subject: Re: Spawn example bugs; various questions At Wed Jul 22 12:30:45 1998, Ioannis Zannos wrote: > >Hello, > >the first two examples from the newest Spawn.help file >keep freezing on my 604/200 PPC for no understandable reason. >The second example (...FSinOsc.ar(2000.0.rand, EnvGen.kr(e)),...) >crashes especially when I stop it with command-. It will >keep playing, but the mac freezes. I can't reproduce these. Have you tried increasing your RAM partition? How much CPU usage are you getting? > >And some other questions or remarks - I hope it is >OK to post them directly here. > >- What are ~, <, >, <> ~myvar acesses an environment variable. It is a shorthand for: 'myvar'.envirGet; >What is the meaning of the followintg prefixes: ~, <, >, <> to variables? < > <> are explained in "09 Classes" They are a shorthand way to create getter and setter methods for an instance variable. var x; is equivalent to defining the following setter method: x_ { arg aValue; x = aValue; } var <>x; // defines both getter and setter methods. >I assume ~ means "get the value of the variable from the actual >environment". But it is not clear how the environment mechanism >functions and what it is good for - assume again a scheme similar >to tempo base of SC1.f and pyrite, but more general, applying >to other values also (frequency etc.). >The multitude of pattern, stream and environment subclasses >suggests something fascinating has happened there >like with the UGens, but there is no doc about it yet. >I am studying the pat examples, but it's slow work. Better to wait until I can document Environments and Patterns. They are rather involved for an email explanation. > >- When does one use ^ to return - when not? >Is there a particular reason for doing away with ^ as return operator >in class methods, but retaining it in function closures (blocks?) Methods always return the receiver (i.e. this) by default if there is no explicit return via ^ . A block always returns the value of its expression. You can put an ^ return in a block, and that will return not from the block but from the enclosing method. When you are in the interpreter there is no enclosing method so using ^ in the interpreter exits the interpreter. > >- How to trigger patterns and/or sounds from GUI items? >For example, how to realise the same thing as following SC1.x program, >where the check-box gui items 1 and 2 are connected to "LowAndSlow" >and "HighAndFast" respectively?: I've tested this, but I had to retype it in, so I may have introduced a typo.. ( var e, w, box1, box2, ping; // generated with the GUI builder, then modified: w = GUIWindow.new("panel", Rect.new( 128, 64, 528, 464 )); box1 = CheckBoxView.new( w, Rect.new( 18, 15, 146, 35 ), "Low and Slow", 0, 0, 1, 0, 'linear'); box2 = CheckBoxView.new( w, Rect.new( 18, 39, 146, 59 ), "High and Fast", 0, 0, 1, 0, 'linear'); // envelope dur will be scaled via the time scaling parameter in EnvGen e = Env.new([0,1,0],[0.5, 0.5]); // define function for instrument ping = { arg freq = 400, dur = 1, amp = 0.3; EnvGen.ar(e, SinOsc.ar(freq), 0, amp, 0, dur); }; Synth.play( Spawn.ar({ if ( box1.value > 0, { // poll value of GUI item ping.value; // return ugen graph }); // otherwise if returns nil }, 1, 1) // numchannels, nexttime + // add two spawns together Spawn.ar({ if (box2.value > 0, { ping.value(900, 2/5); }); }, 1, 2/5) )) You may want to keep in mind the Pause ugen in some situations rather than the above. ------------------------------ Date: Thu, 23 Jul 1998 10:56:59 +0200 From: Ioannis Zannos <---@---.---> Subject: Re: Scheduling with spawn [Also polling the mouse ... et al.] At 1:31 PM -0700 22.7.1998, James McCartney wrote: >At Wed Jul 22 12:30:45 1998, Ioannis Zannos wrote: <..... snip ... > > >var >x; > >is equivalent to defining the following setter method: > >x_ { arg aValue; x = aValue; } > >var <>x; // defines both getter and setter methods. What about something like: numbox.value = mousex.value; or sp.nexttime = 0.2; Why not use the "regular" setter methods like numbox.value_(mousex.value); Is there a difference? > >I've tested this, but I had to retype it in, so I may have introduced a typo.. > >( >var e, w, box1, box2, ping; >// generated with the GUI builder, then modified: >w = GUIWindow.new("panel", Rect.new( 128, 64, 528, 464 )); >box1 = CheckBoxView.new( w, Rect.new( 18, 15, 146, 35 ), "Low and Slow", > 0, 0, 1, 0, 'linear'); >box2 = CheckBoxView.new( w, Rect.new( 18, 39, 146, 59 ), "High and Fast", > 0, 0, 1, 0, 'linear'); > >// envelope dur will be scaled via the time scaling parameter in EnvGen >e = Env.new([0,1,0],[0.5, 0.5]); > >// define function for instrument >ping = { arg freq = 400, dur = 1, amp = 0.3; > EnvGen.ar(e, SinOsc.ar(freq), 0, amp, 0, dur); >}; > >Synth.play( > Spawn.ar({ > if ( box1.value > 0, { // poll value of GUI item > ping.value; // return ugen graph > }); // otherwise if returns nil > }, 1, 1) // numchannels, nexttime > + // add two spawns together > Spawn.ar({ > if (box2.value > 0, { > ping.value(900, 2/5); > }); > }, 1, 2/5) >)) > > >You may want to keep in mind the Pause ugen in some situations rather >than the above. Thanks for showing how to spawn processes in parallel! But, as you suggest in your other answer: >You can execute >a block in the Sequencer object upon receiving a trigger from >something like a ControlIn which can be linked to a GUI item or >MIDI key. There will also be ways of starting an event in a Spawn >externally, but that is not done yet. it seems more appropriate to use ControlIn in conjunction with trigger right? And to your other answer: At 9:46 AM -0700 22.7.1998, James McCartney wrote: >At Wed Jul 22 12:46:43 1998, Ioannis Zannos wrote: <... snip ...> >>Furthermore, how can one make the evaluation of something >>(e.g. start of a sound or of a computation process) >>depending on input from the user/environment? >>(See also my last example about starting from GUI items) > >You do not have to return a ugen graph, you can return nil. Yes, its in the doc and I should have experimented with it earlier. See below. >Scheduling can be done in several ways. You can use the Spawn >event function. You can use a Synth task (not yet documented, >but the "z analog variant" example uses one). You can execute >a block in the Sequencer object upon receiving a trigger from >something like a ControlIn which can be linked to a GUI item or >MIDI key. There will also be ways of starting an event in a Spawn >externally, but that is not done yet. > >It is not possible to implement sched in the same way for SC2 because >computations do not happen exactly in sync. Due to the sample accurate >start times, each voice's buffer is shifted in time with the others. >So there are multiple time streams not just one. That is why you have >Synth tasks scheduled per synth. Very high quality stuff - both the trigger solution and the sample accurate shifting of voice buffers!!! I will be working on on Sequencer, ControlIn, from the present doc, perhaps examples can result from that... I still wonder what load is involved in the extra UGen created by Spawn, and what Pause has to do with this when running many Spawns in parallel. Finally, an example of polling and displaying the mouse using a Spawn process returning nil: - ------------------------------------------- // 1. Poll and display the mouse, with no sound output ( var w, mxd, myd, cd, mousex, mousey; // the mouse polling functions; mousex = MouseX.new(0.0, 1.0); mousey = MouseY.new(0.0, 1.0); // build the gui window and its items. Generated from GUI builder. w = GUIWindow.new("mouse display", Rect.new( 100, 100, 300, 200 )); StringView.new( w, Rect.new( 15, 15, 85, 35 ), "mouse x").prSetBorderStyle(2); mxd= NumericalView.new( w, Rect.new( 94, 15, 158, 35 ), "NumericalView", 0, 0, 1, 0); StringView.new( w, Rect.new( 15, 39, 85, 59 ), "mouse y").prSetBorderStyle(2); myd= NumericalView.new( w, Rect.new( 94, 39, 158, 59 ), "NumericalView", 0, 0, 1, 0); StringView.new( w, Rect.new( 15, 63, 85, 83 ), "poll count").prSetBorderStyle(2); cd= NumericalView.new( w, Rect.new( 94, 63, 158, 83 ), "NumericalView", 0, 0, 1, 0); // the poll and display process; Synth.play( Spawn.ar({ arg sp, i; mxd.value = mousex.value; // display mouse x myd.value = mousey.value; // display mouse y cd.value = i; // display how many times the display function was called. nil; }, 1, 0.1) ); ) - ------------------------------------------- Regards, I.Z. - ----------------------------------- Ioannis Zannos Staatliches Institut fuer Musikforschung Tiergartenstr. 1, D-10785 Berlin, Germany Tel: +49 30 25481140 Fax: +49 30 25481172 ------------------------------ End of sc-users-digest V1 #3 ****************************