jamshark70
Y'all know me from the list...
jamshark70's code
Sound file chunks: Workaround for single-precision buffer indexing
One of the common questions on the list is about handling very large sound files with BufRd. BufRd indexes into the buffer using a single-precision float, which supports buffers only up to 2**24 frames (a bit more than six minutes at 44.1 kHz). This approach loads sequential chunks of a sound file into buffers that are within reach of BufRd. Then, the SynthDef can advance from one buffer to the next during playback. Each buffer holds one extra sample, to try to give BufRd's linear interpolation enough information to work with. There may or may not be an off-by-one bug here. If you find a problem, let me know.
Abusing Convolution2 to make pitch
Inspired by Formlet, which does something like formant synthesis by outputting short sinusoidal grains in response to impulses, I thought, what if we replace the sine grains with an arbitrary impulse response? You could do that with TGrains, but as the pitch goes up, so does the number of overlapping grains and CPU use along with it. But, convolution of a chain of impulses should be the same as granular synthesis, if the grain contents are used as the convolution kernel (impulse response). The first example does this with a buffer containing BrownNoise (shaped by a Hanning envelope). The second example adds timbre control by crossfading between three different Convolution2 results. To avoid clicks in the output when crossing buffer boundaries, I had to ensure that even-numbered buffers always go into XFade2's leftmost input and odd ones into the second input. (Note, the second example could be made more efficient/scalable by using just two Convolution2 units, and providing a trigger to the third input whenever its calculated buffer number changes. Exercise for the reader...)
ScoreClock, Patterns, RT/NRT and server-side resources
1A quick demo of one way to allocate server-side resources (SynthDefs, Buffers) that works in RT/NRT with minimal modification. You'll need Jonatan Liljedahl's ScoreClock quark: // Mac OSX / Linux Quarks.install("ScoreClock"); // Windows, see http://swiki.hfbk-hamburg.de/MusicTechnology/883
demo: backtracking constraint solver
1A quick and dirty recursive approach to finding valid solutions for a set of constraints by backtracking. The constraints are: Given a set of phrases (defined as Pbinds), randomly string them together so that the total duration is one "bar" (where the bar could have any number of beats, of course -- here it's 9). A phrase can be truncated, but it's not valid to change the duration of a note. That's for the first version of the ~backtracking function. The second version adds one more constraint: the bar must not end with a 16th note. The only difference between the two versions is an additional condition in the 'case' statement, which causes the solution to be rejected if the last duration is 0.25.
Visual demonstration of aliasing/foldover
2 1I needed to demonstrate the importance of the Nyquist frequency to a class, so I wrote this visual, interactive demonstration. Use the slider at the bottom to set the frequency -- 1.0 corresponds to one cycle shown in the window. Tested with Qt and Swing GUIs. Should work in cocoa, but not tested.
Community comments