From djscholten@mitre.org Tue Jan 2 13:12:08 2007 From: djscholten@mitre.org (Scholten, Dan) Date: Tue, 2 Jan 2007 08:12:08 -0500 Subject: [Stk] UdpSocket Message-ID: This is a multi-part message in MIME format. ------_=_NextPart_001_01C72E6F.9B994792 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I'm using the UdpSocket class from the STK and had a question on the readBuffer function. I want to call this method from a callback that runs on a set time interval (say every 30 seconds), but I'm not guaranteed to have received data since the last readBuffer call was made. It seems that this method will block until data is received before continuing. I wish the program to just continue execution regardless if any data was received or not. Is there a precheck I can make to see if the socket has received any data or a way to make the readBuffer call "timeout" if it does not receive data within a certain time frame? =20 Thanks, Dan Scholten ------_=_NextPart_001_01C72E6F.9B994792 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
I'm = using the UdpSocket class from the STK and = had a=20 question on the readBuffer function.  I want to call this method = from a=20 callback that runs on a set time interval (say every 30 seconds), but = I'm not=20 guaranteed to have received data since the last readBuffer call was = made. =20 It seems that this method will block until data is received before=20 continuing.  I wish the program to just continue execution = regardless if=20 any data was received or not.  Is there a precheck I can make to = see if the=20 socket has received any data or a way to make the readBuffer call = "timeout" if=20 it does not receive data within a certain time = frame?
 
Thanks,
Dan=20 Scholten
------_=_NextPart_001_01C72E6F.9B994792-- From gary@ccrma.Stanford.EDU Tue Jan 2 19:42:14 2007 From: gary@ccrma.Stanford.EDU (Gary P. Scavone) Date: Tue, 2 Jan 2007 14:42:14 -0500 Subject: [Stk] RtAudio application/port name (for jack in particular) In-Reply-To: <4595EBE5.8060000@mail.mcgill.ca> References: <7671030.1162310597768.JavaMail.R.Ellis5878@student.leedsmet.ac.uk> <4595EBE5.8060000@mail.mcgill.ca> Message-ID: <15B99891-747C-46AC-AACE-E8411159E168@ccrma.stanford.edu> Hi Stephen, Thanks for the comments. I already made a change to RtMidi that allows one to name virtual MIDI ports in ALSA and OS-X (via the openVirtualPort() function). The currently distributed version has this (http://www.music.mcgill.ca/~gary/rtmidi/classRtMidi.html). I'm currently working on a new version of RtAudio and something similar should happen there for Jack. At the moment, I'm trying to "nail down" the new API in OS-X before propagating it to the other supported audio APIs. The port naming feature is API-specific so I'll need to find a consistent way to support it. Regards, --gary On 29-Dec-06, at 11:32 PM, Stephen Sinclair wrote: > Hello, > > In a program I have written using RtAudio, I have mostly been using > it with ALSA. Recently I thought I'd see how it would work with > Jack. It works quite well! > One thing I noticed though is that the Jack device always shows up > as "RtApiJack" instead of something meaningful with the > application's name. > > Would it be beneficial to add some mechanism to the RtAudio object > to specify the application name? > It would be useful also for RtMidi, with the ALSA device name. > Currently it just shows up as RtMidi Input or RtMidi Output. > > By the way, a quick test just showed me that a very real problem > with not having unique names for the Jack device is that when you > run more than one application that uses RtAudio, only the first one > shows up in the "Connect" dialog in qjackctl. I guess ideally > you'd not only want a unique name for the application, but also a > unique name between instances of the same application. Not sure > how to approach that problem.. > > Another thing I noticed today is that sometimes I get some major > clicking or other kinds of distortion if my application's buffer > sizes don't match well with the Jack settings. Is this a common > Jack problem? I haven't used Jack much, and certainly not with any > non-RtAudio applications, so I have nothing to compare with. > > > Steve > ps., this post is just to get some opinions on the topic. I'll > probably try it and post a patch sometime soon. > > _______________________________________________ > Stk mailing list > Stk@ccrma.stanford.edu > http://ccrma-mail.stanford.edu/mailman/listinfo/stk From gary@ccrma.Stanford.EDU Wed Jan 3 17:19:45 2007 From: gary@ccrma.Stanford.EDU (Gary P. Scavone) Date: Wed, 3 Jan 2007 12:19:45 -0500 Subject: [Stk] UdpSocket In-Reply-To: References: Message-ID: <52B72787-A85C-4BEB-AD55-432ED1A17F29@ccrma.stanford.edu> Hi Dan, The base class of UdpSocket (Socket) offers a static function called "setBlocking()" that can be used to set the socket as non-blocking. I haven't used those classes extensively so I cannot say for sure how the read() function will behave if the socket is non-blocking. It is possible that it may return a -1 if no data is available, though that might not be a problem for you. Another option is to get the socket descriptor via the id() function and then call the "select" function (not part of the class) to find out if data is available for reading or not. The select() function is available on most systems and is used in the Messager class in this way. Regards, --gary On 2-Jan-07, at 8:12 AM, Scholten, Dan wrote: > I'm using the UdpSocket class from the STK and had a question on > the readBuffer function. I want to call this method from a > callback that runs on a set time interval (say every 30 seconds), > but I'm not guaranteed to have received data since the last > readBuffer call was made. It seems that this method will block > until data is received before continuing. I wish the program to > just continue execution regardless if any data was received or > not. Is there a precheck I can make to see if the socket has > received any data or a way to make the readBuffer call "timeout" if > it does not receive data within a certain time frame? > > Thanks, > Dan Scholten From satellitebiker@gmail.com Fri Jan 5 18:27:24 2007 From: satellitebiker@gmail.com (SatelliteBiker) Date: Fri, 5 Jan 2007 12:27:24 -0600 Subject: [Stk] Creating a THX-like sound Message-ID: Hi all, Some time ago I read an interview with the person who created the THX sound logo, and his use of a dedicated audio computer to generate the sound. It's an interesting read. Found it: http://musicthing.blogspot.com/2005/05/tiny-music-makers-pt-3-thx-sound.html The idea of shifting the tones in the THX sound looked like a fun problem, but I couldn't get my code to work well. I found STK the other day and it made this problem much easier. What I've done is create a number of Bowed instruments wrapped in a "Cello" class (a better name might be ShiftingBowed or something). The Cello class maintains the initial and target frequencies, shift times and various other random data, and as ticks increase the values are adjusted. The code currently only uses 8 Bowed objects, not the 30 used in the real THX. The code accepts one command line argument, an integer, which is the random number seed for repeatable generations. The code runs for about four seconds (on a Macbook Pro) to generate the 13 second wav file. As for the actual sound, the Bowed instruments randomly start within the first 1/4 second of the sound, shift their frequencies to their assigned targets over five seconds, and hold the final chord until the 10-second mark. The reverb gives a ringing finish for a few seconds. All that said, don't expect this example to sound anywhere near as good as the real THX logo. Source code and one sound example are available at: http://www.relro.net/audio/genthx1.cpp http://www.relro.net/audio/thx.wav (2.2MB) I have lots of questions about STK that I couldn't find in the mail archive or class documentation: Easy questions: * What values are valid for the various amplitude, rate, velocity, etc parameters to the Bowed class? * Are sample values from STK instruments always within [-1, 1]? * To mix several instruments, is a simple weighted sum of the samples the idea? (And adjust the weights to keep the sum in [-1, 1]?) * When adding to a SineWave's phase, is the value in radians or a unit of time/samples? * In non-RT code, is it better to call the noteOn()/noteOff() methods of Bowed, or the start/stopBowing() methods? Bigger questions: * How can I get a better sound out of the Bowed instrument? What parameters produce more of a bass sound (or cello, or violin)? Along those lines, would a "bow position" of 0.5 produce louder fundamentals than harmonics? * I'd like to use a sampled cello sound. If I use a WaveLoop with the example sound sampled at 44.1khz, how much of that clip is needed? What are the rules of thumb to using a fixed sample w.r.t to generating a different frequency? * Is there a STK class (or combination of classes) to generate an N-harmonic sound wave? Instead of using a cello WaveLoop, maybe combine SineWaves at the desired harmonics? Maybe another, more efficient method? Thanks for STK. It's a neat library. -Brent Burton p.s. I welcome all comments and suggestions for improving this sound, from instrument selection to final chord. From prc@CS.Princeton.EDU Mon Jan 8 20:50:30 2007 From: prc@CS.Princeton.EDU (Perry R Cook) Date: Mon, 8 Jan 2007 15:50:30 -0500 (EST) Subject: [Stk] Creating a THX-like sound In-Reply-To: References: Message-ID: Inspired by this STK version, I knocked one together in ChucK: 30 oscillators work fine on a fairly old Mac. // THX emulator, Perry R. Cook, Jan. 8, 2007 // // F-1, B1b, F1, B2b, F2, B3b, F3, A5, F4, A6 [ 29.0, 87.5,116.0,175.0,233.0,350.0,524.0,880.0,1048,1760, 29.0, 87.5,116.0,175.0,233.0,350.0,524.0,880.0,1048,1760, 29.0, 87.5,116.0,175.0,233.0,350.0,524.0,880.0,1048,1760 ] @=> float targets[]; float initials[30]; float deltas[30]; sawosc s[30]; gain gl[30]; gain gr[30]; JCRev rl => dac.left; JCRev rr => dac.right; 0 => int i => int j; for (0 => i; i<30; i+1 => i) { std.rand2f(200.0,800.0) => initials[i] => s[i].freq; // random freqs. (targets[i] - initials[i]) / 10000.0 => deltas[i]; // 10 sample updates 0.1 => s[i].gain; std.rand2f(0.0,1.0) => gl[i].gain; // random 1.0 - gl[i].gain() => gr[i].gain; // panning s[i] => gl[i] => rl; // hook up s[i] => gr[i] => rr; // all the oscs } 10000 :: samp => now; // steady cluster while(j < 10000) { for (0 => i; i<30; i+1 => i) { initials[i] + (deltas[i]*j) => s[i].freq; // sweep freqs. } j + 1 => j; 10 :: samp => now; } while (j < 30000) { // hold chord 10 :: samp => now; j + 1 => j; } while (j < 35000) { for (0 => i; i<30; i+1 => i) { 0.1 * (35000 - j) / 10000.0 => s[i].gain; // decay gains } 10 :: samp => now; j + 1 => j; } 60000 :: samp => now; // reverb tail From gary@ccrma.Stanford.EDU Wed Jan 10 16:24:30 2007 From: gary@ccrma.Stanford.EDU (Gary P. Scavone) Date: Wed, 10 Jan 2007 11:24:30 -0500 Subject: [Stk] Creating a THX-like sound In-Reply-To: References: Message-ID: Hi Brent, Thanks for the email ... the information and sound was very nice! Here are some answers to your questions: > Easy questions: > * What values are valid for the various amplitude, rate, velocity, > etc parameters to the Bowed class? That is not an easy question. :-) In general, finding "proper" parameter values for physical models requires much experimentation. > * Are sample values from STK instruments always within [-1, 1]? Yes, they are expected to fall in that range but there is no internal clipping. Definitely, they need to be in that range when they are output to a file or the RtAudio class. > * To mix several instruments, is a simple weighted sum of the samples > the idea? (And adjust the weights to keep the sum in [-1, 1]?) Basically. > * When adding to a SineWave's phase, is the value in radians or a > unit of time/samples? When using the addPhase() function of the SineWave class, the "angle" argument is multiplied by the table size and the read pointer is incremented by that amount. So, an argument value of 1.0 would increment the read pointer by one complete table size (or 2*pi radians), which would put it back where it started. Thus, unique values are in the range 0.0 - 1.0 but you can provide values outside that range. > * In non-RT code, is it better to call the noteOn()/noteOff() > methods of Bowed, or the start/stopBowing() methods? You should look at the code but the noteOn()/noteOff() functions may do a few other things that do not happen in the start/stopBowing functions. > Bigger questions: > * How can I get a better sound out of the Bowed instrument? What > parameters produce more of a bass sound (or cello, or violin)? > Along those lines, would a "bow position" of 0.5 produce louder > fundamentals than harmonics? The bow position argument does not correspond to a full string-length distance. That is, a value of 0.5 does not correspond to bowing in the center of the string. From from quick tests, it appears that the loudest sounds occur for values around 0.5, with more high frequency content using lower values. > * I'd like to use a sampled cello sound. If I use a WaveLoop with the > example sound sampled at 44.1khz, how much of that clip is needed? > What > are the rules of thumb to using a fixed sample w.r.t to generating > a different > frequency? I'm not sure I completely understand your question but WaveLoop will cycle your entire sound file. Determining the exact sounding frequency will depend on the frequency of the original sound. > * Is there a STK class (or combination of classes) to generate an N- > harmonic > sound wave? Instead of using a cello WaveLoop, maybe combine SineWaves > at the desired harmonics? Maybe another, more efficient method? No but you can use many SineWaves to do that (as Perry indicated via ChucK). Regards, --gary From satellitebiker@gmail.com Fri Jan 12 02:30:22 2007 From: satellitebiker@gmail.com (SatelliteBiker) Date: Thu, 11 Jan 2007 20:30:22 -0600 Subject: [Stk] Creating a THX-like sound In-Reply-To: References: Message-ID: Gary, thanks for all the answers and wading through my post. I appreciate it. And Perry, thanks for the ChucK example. I also downloaded that language and had it running immediately (OSX). In my original code I doubled up on the two lowest frequencies to boost their contribution as described in the interview; that improved the sound a little. FWIW, the sample sound I shared was seeded with 1243 on the command line (should your rand() function sequence the same). These are some interesting tools, and I look forward to using them more. -Brent