Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Michael Heuer
Note there are also a few different sample-hold chubgraphs in LiCK

https://github.com/heuermh/lick/tree/master/lick/lfo 


Cheers!

   michael


> On Apr 20, 2020, at 2:10 PM, Forrest Curo  wrote:
> 
> Yes, I'm interested!
> Whatever turns out easier, one could apply it to note lengths, amplitudes, 
> other parameters  in same way for same reasons: a bit of patterned randomness.
> 
> On Mon, Apr 20, 2020 at 11:32 AM Mario Buoninfante 
> mailto:mario.buoninfa...@gmail.com>> wrote:
> Hi,
> 
> In case you're interested I made a SampHold chugin that you can find here: 
> https://github.com/mariobuoninfante/ChucK_chugins 
> 
> 
> Cheers,
> Mario
> 
> On Mon, 20 Apr 2020 at 18:05, Forrest Curo  > wrote:
> "A sample and hold uses a periodic wave as an input. The wave is sampled at 
> regular
> intervals. The resulting values are used as a control. It "samples" the wave 
> and "holds" that
> value until a new value is sampled. It can be thought of as an analog to 
> digital converter with
> a low frequency sampling rate (though technically the wave being sampled is 
> also digital).
> The effect is similar to a strobe light or motion picture film taking 
> snapshots of a smooth
> process. That smooth process is then quantized into discrete steps.
> 
> "How is this useful in synthesis? Why would you want to freeze-frame a wave 
> form?
> The idea is that even though the sample rate is too low to accurately 
> represent the true shape
> of the wave, patterns will still emerge because the wave is periodic, and the 
> sample rate is
> periodic."
> 
> [David Cottle, _Computer Music with Examples in Supercollider 3]
> 
> (This can be done in ChucK; the sndBuf containing the wave can be sampled via 
> .valueAt without directly playing it.)
> 
> On Sun, Apr 19, 2020 at 9:50 PM Forrest Curo  > wrote:
> I've achieved  dreadfulness with this. Okay, will vary the rhythm etc and 
> reduce the range, get a more interesting scale, but... hmm!
> SawOsc s => JCRev r => dac;
> .1 => s.gain;
> .1 => r.mix;
> 1 => int incsamp;
> 0 => int ps;
> 1 => float height;
> 0 => float maxsofar;
> 0 => float freq;
> SndBuf buf;
> 
> "/home/forrest/chuck/examples/basic/om.wav" => buf.read;
> 
> buf.samples()  => int numSamples;
>  Std.rand2(1, numSamples-1) => incsamp;
> while(true){
> (incsamp + ps) % numSamples => ps;
> buf.valueAt(ps) + 0.125 => height;
> Std.mtof(Math.ceil(Std.fabs(500.0 * height)) ) => freq => s.freq;
> 
> if(freq > maxsofar) {
> freq => maxsofar;
> <<< maxsofar >>>;
> }
> 0.75::second => now;
> }
> 
> 
> 
> 
> 
> 
> On Sun, Apr 19, 2020 at 1:42 PM Forrest Curo  > wrote:
> Um. that works.
> So does this:
> SndBuf s => blackhole; 
> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
> float samples;
> 0 => int i;
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> s.pos() => i;
> (s.valueAt(i)) => samples;
> <<< samples >>>;
> samp => now;
> }
> 
> I was having trouble trying to read a sndBuf like an array, or put its 
> contents into an array.
> Maybe I was reading numbers off the end of the file. Declaring 
> 'float samples[]; '
> and doing
> 's.valueAt(i) => samples[i];'
> 
> got me a 'Null pointer' error. 
> 
> Stumbling over syntax, I guess. Thanks for help!
> 
> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  > wrote:
> This is truly odd.  I don’t have easy means to test it.   I don’t 
> know why it wouldbe broken dependent on the dac, however.
> 
> For fun you might try something like this, just to verify that the
> valueAt() function is what’s busted.
> 
> SndBuf s => blackhole;  
> “Fred.wav” => s.read;
> 
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> samp => now;
> }
> 
> PRC
> 
> > On Apr 19, 2020, at 9:00 AM, chuck-users-requ...@lists.cs.princeton.edu 
> >  wrote:
> > 
> > Send chuck-users mailing list submissions to
> >   chuck-users@lists.cs.princeton.edu 
> > 
> > 
> > To subscribe or unsubscribe via the World Wide Web, visit
> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users 
> > 
> > or, via email, send a message with subject or body 'help' to
> >   chuck-users-requ...@lists.cs.princeton.edu 
> > 
> > 
> > You can reach the person managing the list at
> >   chuck-users-ow...@lists.cs.princeton.edu 
> > 
> > 
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of chuck-users digest..."
> > 
> > 
> > Today's Topics:
> > 
> >   1. sndBuf.valueAt (Forrest Curo)
> > 
> > 
> > 

Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Forrest Curo
Yes, I'm interested!
Whatever turns out easier, one could apply it to note lengths, amplitudes,
other parameters  in same way for same reasons: a bit of patterned
randomness.

On Mon, Apr 20, 2020 at 11:32 AM Mario Buoninfante <
mario.buoninfa...@gmail.com> wrote:

> Hi,
>
> In case you're interested I made a SampHold chugin that you can find here:
> https://github.com/mariobuoninfante/ChucK_chugins
>
> Cheers,
> Mario
>
> On Mon, 20 Apr 2020 at 18:05, Forrest Curo  wrote:
>
>> "A sample and hold uses a periodic wave as an input. The wave is sampled
>> at regular
>> intervals. The resulting values are used as a control. It "samples" the
>> wave and "holds" that
>> value until a new value is sampled. It can be thought of as an analog to
>> digital converter with
>> a low frequency sampling rate (though technically the wave being sampled
>> is also digital).
>> The effect is similar to a strobe light or motion picture film taking
>> snapshots of a smooth
>> process. That smooth process is then quantized into discrete steps.
>>
>> "How is this useful in synthesis? Why would you want to freeze-frame a
>> wave form?
>> The idea is that even though the sample rate is too low to accurately
>> represent the true shape
>> of the wave, patterns will still emerge because the wave is periodic, and
>> the sample rate is
>> periodic."
>>
>> [David Cottle, _Computer Music with Examples in Supercollider 3]
>>
>> (This can be done in ChucK; the sndBuf containing the wave can be sampled
>> via .valueAt without directly playing it.)
>>
>> On Sun, Apr 19, 2020 at 9:50 PM Forrest Curo 
>> wrote:
>>
>>> I've achieved  dreadfulness with this. Okay, will vary the rhythm etc
>>> and reduce the range, get a more interesting scale, but... hmm!
>>> SawOsc s => JCRev r => dac;
>>> .1 => s.gain;
>>> .1 => r.mix;
>>> 1 => int incsamp;
>>> 0 => int ps;
>>> 1 => float height;
>>> 0 => float maxsofar;
>>> 0 => float freq;
>>> SndBuf buf;
>>>
>>> "/home/forrest/chuck/examples/basic/om.wav" => buf.read;
>>>
>>> buf.samples()  => int numSamples;
>>>  Std.rand2(1, numSamples-1) => incsamp;
>>> while(true){
>>> (incsamp + ps) % numSamples => ps;
>>> buf.valueAt(ps) + 0.125 => height;
>>> Std.mtof(Math.ceil(Std.fabs(500.0 * height)) ) => freq => s.freq;
>>>
>>> if(freq > maxsofar) {
>>> freq => maxsofar;
>>> <<< maxsofar >>>;
>>> }
>>> 0.75::second => now;
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sun, Apr 19, 2020 at 1:42 PM Forrest Curo 
>>> wrote:
>>>
 Um. that works.
 So does this:
 SndBuf s => blackhole;
 "/home/forrest/chuck/examples/basic/om.wav" => s.read;
 float samples;
 0 => int i;
 while (s.pos() < s.samples())  {
 <<< s.last() >>>;
 s.pos() => i;
 (s.valueAt(i)) => samples;
 <<< samples >>>;
 samp => now;
 }

 I was having trouble trying to read a sndBuf like an array, or put its
 contents into an array.
 Maybe I was reading numbers off the end of the file. Declaring
 'float samples[]; '
 and doing
 's.valueAt(i) => samples[i];'

 got me a 'Null pointer' error.

 Stumbling over syntax, I guess. Thanks for help!

 On Sun, Apr 19, 2020 at 10:54 AM Perry Cook 
 wrote:

> This is truly odd.  I don’t have easy means to test it.   I don’t
> know why it wouldbe broken dependent on the dac, however.
>
> For fun you might try something like this, just to verify that the
> valueAt() function is what’s busted.
>
> SndBuf s => blackhole;
> “Fred.wav” => s.read;
>
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> samp => now;
> }
>
> PRC
>
> > On Apr 19, 2020, at 9:00 AM,
> chuck-users-requ...@lists.cs.princeton.edu wrote:
> >
> > Send chuck-users mailing list submissions to
> >   chuck-users@lists.cs.princeton.edu
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > or, via email, send a message with subject or body 'help' to
> >   chuck-users-requ...@lists.cs.princeton.edu
> >
> > You can reach the person managing the list at
> >   chuck-users-ow...@lists.cs.princeton.edu
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of chuck-users digest..."
> >
> >
> > Today's Topics:
> >
> >   1. sndBuf.valueAt (Forrest Curo)
> >
> >
> >
> --
> >
> > Message: 1
> > Date: Sun, 19 Apr 2020 07:30:15 -0700
> > From: Forrest Curo 
> > To: ChucK Users Mailing List 
> > Subject: [chuck-users] sndBuf.valueAt
> > Message-ID:
> >    g...@mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Using chuck linux-jack this gives me reasonable numbers between -1
> and 1.
> > Using 

Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Mario Buoninfante
Hi,

In case you're interested I made a SampHold chugin that you can find here:
https://github.com/mariobuoninfante/ChucK_chugins

Cheers,
Mario

On Mon, 20 Apr 2020 at 18:05, Forrest Curo  wrote:

> "A sample and hold uses a periodic wave as an input. The wave is sampled
> at regular
> intervals. The resulting values are used as a control. It "samples" the
> wave and "holds" that
> value until a new value is sampled. It can be thought of as an analog to
> digital converter with
> a low frequency sampling rate (though technically the wave being sampled
> is also digital).
> The effect is similar to a strobe light or motion picture film taking
> snapshots of a smooth
> process. That smooth process is then quantized into discrete steps.
>
> "How is this useful in synthesis? Why would you want to freeze-frame a
> wave form?
> The idea is that even though the sample rate is too low to accurately
> represent the true shape
> of the wave, patterns will still emerge because the wave is periodic, and
> the sample rate is
> periodic."
>
> [David Cottle, _Computer Music with Examples in Supercollider 3]
>
> (This can be done in ChucK; the sndBuf containing the wave can be sampled
> via .valueAt without directly playing it.)
>
> On Sun, Apr 19, 2020 at 9:50 PM Forrest Curo 
> wrote:
>
>> I've achieved  dreadfulness with this. Okay, will vary the rhythm etc and
>> reduce the range, get a more interesting scale, but... hmm!
>> SawOsc s => JCRev r => dac;
>> .1 => s.gain;
>> .1 => r.mix;
>> 1 => int incsamp;
>> 0 => int ps;
>> 1 => float height;
>> 0 => float maxsofar;
>> 0 => float freq;
>> SndBuf buf;
>>
>> "/home/forrest/chuck/examples/basic/om.wav" => buf.read;
>>
>> buf.samples()  => int numSamples;
>>  Std.rand2(1, numSamples-1) => incsamp;
>> while(true){
>> (incsamp + ps) % numSamples => ps;
>> buf.valueAt(ps) + 0.125 => height;
>> Std.mtof(Math.ceil(Std.fabs(500.0 * height)) ) => freq => s.freq;
>>
>> if(freq > maxsofar) {
>> freq => maxsofar;
>> <<< maxsofar >>>;
>> }
>> 0.75::second => now;
>> }
>>
>>
>>
>>
>>
>>
>> On Sun, Apr 19, 2020 at 1:42 PM Forrest Curo 
>> wrote:
>>
>>> Um. that works.
>>> So does this:
>>> SndBuf s => blackhole;
>>> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
>>> float samples;
>>> 0 => int i;
>>> while (s.pos() < s.samples())  {
>>> <<< s.last() >>>;
>>> s.pos() => i;
>>> (s.valueAt(i)) => samples;
>>> <<< samples >>>;
>>> samp => now;
>>> }
>>>
>>> I was having trouble trying to read a sndBuf like an array, or put its
>>> contents into an array.
>>> Maybe I was reading numbers off the end of the file. Declaring
>>> 'float samples[]; '
>>> and doing
>>> 's.valueAt(i) => samples[i];'
>>>
>>> got me a 'Null pointer' error.
>>>
>>> Stumbling over syntax, I guess. Thanks for help!
>>>
>>> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook 
>>> wrote:
>>>
 This is truly odd.  I don’t have easy means to test it.   I don’t
 know why it wouldbe broken dependent on the dac, however.

 For fun you might try something like this, just to verify that the
 valueAt() function is what’s busted.

 SndBuf s => blackhole;
 “Fred.wav” => s.read;

 while (s.pos() < s.samples())  {
 <<< s.last() >>>;
 samp => now;
 }

 PRC

 > On Apr 19, 2020, at 9:00 AM,
 chuck-users-requ...@lists.cs.princeton.edu wrote:
 >
 > Send chuck-users mailing list submissions to
 >   chuck-users@lists.cs.princeton.edu
 >
 > To subscribe or unsubscribe via the World Wide Web, visit
 >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
 > or, via email, send a message with subject or body 'help' to
 >   chuck-users-requ...@lists.cs.princeton.edu
 >
 > You can reach the person managing the list at
 >   chuck-users-ow...@lists.cs.princeton.edu
 >
 > When replying, please edit your Subject line so it is more specific
 > than "Re: Contents of chuck-users digest..."
 >
 >
 > Today's Topics:
 >
 >   1. sndBuf.valueAt (Forrest Curo)
 >
 >
 > --
 >
 > Message: 1
 > Date: Sun, 19 Apr 2020 07:30:15 -0700
 > From: Forrest Curo 
 > To: ChucK Users Mailing List 
 > Subject: [chuck-users] sndBuf.valueAt
 > Message-ID:
 >   >>> g...@mail.gmail.com>
 > Content-Type: text/plain; charset="utf-8"
 >
 > Using chuck linux-jack this gives me reasonable numbers between -1
 and 1.
 > Using chuck linux-alsa I'm able to play the file I've read into
 sndBuf; but
 > trying to copy it via .valueAt gives absurdly high ["out of range"]
 numbers
 > at each point. [It can be a different high number different times I
 run
 > chuck, but the number it is turns up at every point I sample.]
 >
 > Is there a fix for this? Aside from using jack on a computer where it
 > befnurgles the midi?
 

Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Forrest Curo
Yeah, thanks! Though I ended up not needing an array, I'm pretty new to
this, and can definitely can use help with the "everybody knows" stuff!

Forrest


On Mon, Apr 20, 2020 at 10:09 AM Jack Atherton 
wrote:

> Hey Forrest,
>
> The issue you're having with your float array is that 'float samples[];'
> is only declaring a null reference to an array. If you want it to refer to
> an actual array, you need to specify a length (e.g. float samples[
> s.samples() ];)
>
> ChucK arrays can also be resized (which I only found out recently! (:  ),
> so you can also do this, for example:
>
> float foo[0];
> foo.size(4);
> <<< foo[0], foo[1], foo[2], foo[3] >>>;
>
> ~Jack
>
>
> On Sun, Apr 19, 2020 at 1:43 PM Forrest Curo 
> wrote:
>
>> Um. that works.
>> So does this:
>> SndBuf s => blackhole;
>> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
>> float samples;
>> 0 => int i;
>> while (s.pos() < s.samples())  {
>> <<< s.last() >>>;
>> s.pos() => i;
>> (s.valueAt(i)) => samples;
>> <<< samples >>>;
>> samp => now;
>> }
>>
>> I was having trouble trying to read a sndBuf like an array, or put its
>> contents into an array.
>> Maybe I was reading numbers off the end of the file. Declaring
>> 'float samples[]; '
>> and doing
>> 's.valueAt(i) => samples[i];'
>>
>> got me a 'Null pointer' error.
>>
>> Stumbling over syntax, I guess. Thanks for help!
>>
>> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  wrote:
>>
>>> This is truly odd.  I don’t have easy means to test it.   I don’t
>>> know why it wouldbe broken dependent on the dac, however.
>>>
>>> For fun you might try something like this, just to verify that the
>>> valueAt() function is what’s busted.
>>>
>>> SndBuf s => blackhole;
>>> “Fred.wav” => s.read;
>>>
>>> while (s.pos() < s.samples())  {
>>> <<< s.last() >>>;
>>> samp => now;
>>> }
>>>
>>> PRC
>>>
>>> > On Apr 19, 2020, at 9:00 AM,
>>> chuck-users-requ...@lists.cs.princeton.edu wrote:
>>> >
>>> > Send chuck-users mailing list submissions to
>>> >   chuck-users@lists.cs.princeton.edu
>>> >
>>> > To subscribe or unsubscribe via the World Wide Web, visit
>>> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>> > or, via email, send a message with subject or body 'help' to
>>> >   chuck-users-requ...@lists.cs.princeton.edu
>>> >
>>> > You can reach the person managing the list at
>>> >   chuck-users-ow...@lists.cs.princeton.edu
>>> >
>>> > When replying, please edit your Subject line so it is more specific
>>> > than "Re: Contents of chuck-users digest..."
>>> >
>>> >
>>> > Today's Topics:
>>> >
>>> >   1. sndBuf.valueAt (Forrest Curo)
>>> >
>>> >
>>> > --
>>> >
>>> > Message: 1
>>> > Date: Sun, 19 Apr 2020 07:30:15 -0700
>>> > From: Forrest Curo 
>>> > To: ChucK Users Mailing List 
>>> > Subject: [chuck-users] sndBuf.valueAt
>>> > Message-ID:
>>> >   >> g...@mail.gmail.com>
>>> > Content-Type: text/plain; charset="utf-8"
>>> >
>>> > Using chuck linux-jack this gives me reasonable numbers between -1 and
>>> 1.
>>> > Using chuck linux-alsa I'm able to play the file I've read into
>>> sndBuf; but
>>> > trying to copy it via .valueAt gives absurdly high ["out of range"]
>>> numbers
>>> > at each point. [It can be a different high number different times I run
>>> > chuck, but the number it is turns up at every point I sample.]
>>> >
>>> > Is there a fix for this? Aside from using jack on a computer where it
>>> > befnurgles the midi?
>>> > -- next part --
>>> > An HTML attachment was scrubbed...
>>> > URL: <
>>> http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200419/76d94eef/attachment-0001.html
>>> >
>>> >
>>> > --
>>> >
>>> > ___
>>> > chuck-users mailing list
>>> > chuck-users@lists.cs.princeton.edu
>>> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>> >
>>> >
>>> > End of chuck-users Digest, Vol 176, Issue 4
>>> > ***
>>>
>>> ___
>>> chuck-users mailing list
>>> chuck-users@lists.cs.princeton.edu
>>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>>
>> ___
>> chuck-users mailing list
>> chuck-users@lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
> ___
> chuck-users mailing list
> chuck-users@lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
___
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users


Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Jack Atherton
Hey Forrest,

The issue you're having with your float array is that 'float samples[];' is
only declaring a null reference to an array. If you want it to refer to an
actual array, you need to specify a length (e.g. float samples[ s.samples()
];)

ChucK arrays can also be resized (which I only found out recently! (:  ),
so you can also do this, for example:

float foo[0];
foo.size(4);
<<< foo[0], foo[1], foo[2], foo[3] >>>;

~Jack


On Sun, Apr 19, 2020 at 1:43 PM Forrest Curo  wrote:

> Um. that works.
> So does this:
> SndBuf s => blackhole;
> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
> float samples;
> 0 => int i;
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> s.pos() => i;
> (s.valueAt(i)) => samples;
> <<< samples >>>;
> samp => now;
> }
>
> I was having trouble trying to read a sndBuf like an array, or put its
> contents into an array.
> Maybe I was reading numbers off the end of the file. Declaring
> 'float samples[]; '
> and doing
> 's.valueAt(i) => samples[i];'
>
> got me a 'Null pointer' error.
>
> Stumbling over syntax, I guess. Thanks for help!
>
> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  wrote:
>
>> This is truly odd.  I don’t have easy means to test it.   I don’t
>> know why it wouldbe broken dependent on the dac, however.
>>
>> For fun you might try something like this, just to verify that the
>> valueAt() function is what’s busted.
>>
>> SndBuf s => blackhole;
>> “Fred.wav” => s.read;
>>
>> while (s.pos() < s.samples())  {
>> <<< s.last() >>>;
>> samp => now;
>> }
>>
>> PRC
>>
>> > On Apr 19, 2020, at 9:00 AM, chuck-users-requ...@lists.cs.princeton.edu
>> wrote:
>> >
>> > Send chuck-users mailing list submissions to
>> >   chuck-users@lists.cs.princeton.edu
>> >
>> > To subscribe or unsubscribe via the World Wide Web, visit
>> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>> > or, via email, send a message with subject or body 'help' to
>> >   chuck-users-requ...@lists.cs.princeton.edu
>> >
>> > You can reach the person managing the list at
>> >   chuck-users-ow...@lists.cs.princeton.edu
>> >
>> > When replying, please edit your Subject line so it is more specific
>> > than "Re: Contents of chuck-users digest..."
>> >
>> >
>> > Today's Topics:
>> >
>> >   1. sndBuf.valueAt (Forrest Curo)
>> >
>> >
>> > --
>> >
>> > Message: 1
>> > Date: Sun, 19 Apr 2020 07:30:15 -0700
>> > From: Forrest Curo 
>> > To: ChucK Users Mailing List 
>> > Subject: [chuck-users] sndBuf.valueAt
>> > Message-ID:
>> >   > g...@mail.gmail.com>
>> > Content-Type: text/plain; charset="utf-8"
>> >
>> > Using chuck linux-jack this gives me reasonable numbers between -1 and
>> 1.
>> > Using chuck linux-alsa I'm able to play the file I've read into sndBuf;
>> but
>> > trying to copy it via .valueAt gives absurdly high ["out of range"]
>> numbers
>> > at each point. [It can be a different high number different times I run
>> > chuck, but the number it is turns up at every point I sample.]
>> >
>> > Is there a fix for this? Aside from using jack on a computer where it
>> > befnurgles the midi?
>> > -- next part --
>> > An HTML attachment was scrubbed...
>> > URL: <
>> http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200419/76d94eef/attachment-0001.html
>> >
>> >
>> > --
>> >
>> > ___
>> > chuck-users mailing list
>> > chuck-users@lists.cs.princeton.edu
>> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>> >
>> >
>> > End of chuck-users Digest, Vol 176, Issue 4
>> > ***
>>
>> ___
>> chuck-users mailing list
>> chuck-users@lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
> ___
> chuck-users mailing list
> chuck-users@lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
___
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users


Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-20 Thread Forrest Curo
"A sample and hold uses a periodic wave as an input. The wave is sampled at
regular
intervals. The resulting values are used as a control. It "samples" the
wave and "holds" that
value until a new value is sampled. It can be thought of as an analog to
digital converter with
a low frequency sampling rate (though technically the wave being sampled is
also digital).
The effect is similar to a strobe light or motion picture film taking
snapshots of a smooth
process. That smooth process is then quantized into discrete steps.

"How is this useful in synthesis? Why would you want to freeze-frame a wave
form?
The idea is that even though the sample rate is too low to accurately
represent the true shape
of the wave, patterns will still emerge because the wave is periodic, and
the sample rate is
periodic."

[David Cottle, _Computer Music with Examples in Supercollider 3]

(This can be done in ChucK; the sndBuf containing the wave can be sampled
via .valueAt without directly playing it.)

On Sun, Apr 19, 2020 at 9:50 PM Forrest Curo  wrote:

> I've achieved  dreadfulness with this. Okay, will vary the rhythm etc and
> reduce the range, get a more interesting scale, but... hmm!
> SawOsc s => JCRev r => dac;
> .1 => s.gain;
> .1 => r.mix;
> 1 => int incsamp;
> 0 => int ps;
> 1 => float height;
> 0 => float maxsofar;
> 0 => float freq;
> SndBuf buf;
>
> "/home/forrest/chuck/examples/basic/om.wav" => buf.read;
>
> buf.samples()  => int numSamples;
>  Std.rand2(1, numSamples-1) => incsamp;
> while(true){
> (incsamp + ps) % numSamples => ps;
> buf.valueAt(ps) + 0.125 => height;
> Std.mtof(Math.ceil(Std.fabs(500.0 * height)) ) => freq => s.freq;
>
> if(freq > maxsofar) {
> freq => maxsofar;
> <<< maxsofar >>>;
> }
> 0.75::second => now;
> }
>
>
>
>
>
>
> On Sun, Apr 19, 2020 at 1:42 PM Forrest Curo 
> wrote:
>
>> Um. that works.
>> So does this:
>> SndBuf s => blackhole;
>> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
>> float samples;
>> 0 => int i;
>> while (s.pos() < s.samples())  {
>> <<< s.last() >>>;
>> s.pos() => i;
>> (s.valueAt(i)) => samples;
>> <<< samples >>>;
>> samp => now;
>> }
>>
>> I was having trouble trying to read a sndBuf like an array, or put its
>> contents into an array.
>> Maybe I was reading numbers off the end of the file. Declaring
>> 'float samples[]; '
>> and doing
>> 's.valueAt(i) => samples[i];'
>>
>> got me a 'Null pointer' error.
>>
>> Stumbling over syntax, I guess. Thanks for help!
>>
>> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  wrote:
>>
>>> This is truly odd.  I don’t have easy means to test it.   I don’t
>>> know why it wouldbe broken dependent on the dac, however.
>>>
>>> For fun you might try something like this, just to verify that the
>>> valueAt() function is what’s busted.
>>>
>>> SndBuf s => blackhole;
>>> “Fred.wav” => s.read;
>>>
>>> while (s.pos() < s.samples())  {
>>> <<< s.last() >>>;
>>> samp => now;
>>> }
>>>
>>> PRC
>>>
>>> > On Apr 19, 2020, at 9:00 AM,
>>> chuck-users-requ...@lists.cs.princeton.edu wrote:
>>> >
>>> > Send chuck-users mailing list submissions to
>>> >   chuck-users@lists.cs.princeton.edu
>>> >
>>> > To subscribe or unsubscribe via the World Wide Web, visit
>>> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>> > or, via email, send a message with subject or body 'help' to
>>> >   chuck-users-requ...@lists.cs.princeton.edu
>>> >
>>> > You can reach the person managing the list at
>>> >   chuck-users-ow...@lists.cs.princeton.edu
>>> >
>>> > When replying, please edit your Subject line so it is more specific
>>> > than "Re: Contents of chuck-users digest..."
>>> >
>>> >
>>> > Today's Topics:
>>> >
>>> >   1. sndBuf.valueAt (Forrest Curo)
>>> >
>>> >
>>> > --
>>> >
>>> > Message: 1
>>> > Date: Sun, 19 Apr 2020 07:30:15 -0700
>>> > From: Forrest Curo 
>>> > To: ChucK Users Mailing List 
>>> > Subject: [chuck-users] sndBuf.valueAt
>>> > Message-ID:
>>> >   >> g...@mail.gmail.com>
>>> > Content-Type: text/plain; charset="utf-8"
>>> >
>>> > Using chuck linux-jack this gives me reasonable numbers between -1 and
>>> 1.
>>> > Using chuck linux-alsa I'm able to play the file I've read into
>>> sndBuf; but
>>> > trying to copy it via .valueAt gives absurdly high ["out of range"]
>>> numbers
>>> > at each point. [It can be a different high number different times I run
>>> > chuck, but the number it is turns up at every point I sample.]
>>> >
>>> > Is there a fix for this? Aside from using jack on a computer where it
>>> > befnurgles the midi?
>>> > -- next part --
>>> > An HTML attachment was scrubbed...
>>> > URL: <
>>> http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200419/76d94eef/attachment-0001.html
>>> >
>>> >
>>> > --
>>> >
>>> > ___
>>> > chuck-users mailing list
>>> > chuck-users@lists.cs.princeton.edu

Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-19 Thread Forrest Curo
I've achieved  dreadfulness with this. Okay, will vary the rhythm etc and
reduce the range, get a more interesting scale, but... hmm!
SawOsc s => JCRev r => dac;
.1 => s.gain;
.1 => r.mix;
1 => int incsamp;
0 => int ps;
1 => float height;
0 => float maxsofar;
0 => float freq;
SndBuf buf;

"/home/forrest/chuck/examples/basic/om.wav" => buf.read;

buf.samples()  => int numSamples;
 Std.rand2(1, numSamples-1) => incsamp;
while(true){
(incsamp + ps) % numSamples => ps;
buf.valueAt(ps) + 0.125 => height;
Std.mtof(Math.ceil(Std.fabs(500.0 * height)) ) => freq => s.freq;

if(freq > maxsofar) {
freq => maxsofar;
<<< maxsofar >>>;
}
0.75::second => now;
}






On Sun, Apr 19, 2020 at 1:42 PM Forrest Curo  wrote:

> Um. that works.
> So does this:
> SndBuf s => blackhole;
> "/home/forrest/chuck/examples/basic/om.wav" => s.read;
> float samples;
> 0 => int i;
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> s.pos() => i;
> (s.valueAt(i)) => samples;
> <<< samples >>>;
> samp => now;
> }
>
> I was having trouble trying to read a sndBuf like an array, or put its
> contents into an array.
> Maybe I was reading numbers off the end of the file. Declaring
> 'float samples[]; '
> and doing
> 's.valueAt(i) => samples[i];'
>
> got me a 'Null pointer' error.
>
> Stumbling over syntax, I guess. Thanks for help!
>
> On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  wrote:
>
>> This is truly odd.  I don’t have easy means to test it.   I don’t
>> know why it wouldbe broken dependent on the dac, however.
>>
>> For fun you might try something like this, just to verify that the
>> valueAt() function is what’s busted.
>>
>> SndBuf s => blackhole;
>> “Fred.wav” => s.read;
>>
>> while (s.pos() < s.samples())  {
>> <<< s.last() >>>;
>> samp => now;
>> }
>>
>> PRC
>>
>> > On Apr 19, 2020, at 9:00 AM, chuck-users-requ...@lists.cs.princeton.edu
>> wrote:
>> >
>> > Send chuck-users mailing list submissions to
>> >   chuck-users@lists.cs.princeton.edu
>> >
>> > To subscribe or unsubscribe via the World Wide Web, visit
>> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>> > or, via email, send a message with subject or body 'help' to
>> >   chuck-users-requ...@lists.cs.princeton.edu
>> >
>> > You can reach the person managing the list at
>> >   chuck-users-ow...@lists.cs.princeton.edu
>> >
>> > When replying, please edit your Subject line so it is more specific
>> > than "Re: Contents of chuck-users digest..."
>> >
>> >
>> > Today's Topics:
>> >
>> >   1. sndBuf.valueAt (Forrest Curo)
>> >
>> >
>> > --
>> >
>> > Message: 1
>> > Date: Sun, 19 Apr 2020 07:30:15 -0700
>> > From: Forrest Curo 
>> > To: ChucK Users Mailing List 
>> > Subject: [chuck-users] sndBuf.valueAt
>> > Message-ID:
>> >   > g...@mail.gmail.com>
>> > Content-Type: text/plain; charset="utf-8"
>> >
>> > Using chuck linux-jack this gives me reasonable numbers between -1 and
>> 1.
>> > Using chuck linux-alsa I'm able to play the file I've read into sndBuf;
>> but
>> > trying to copy it via .valueAt gives absurdly high ["out of range"]
>> numbers
>> > at each point. [It can be a different high number different times I run
>> > chuck, but the number it is turns up at every point I sample.]
>> >
>> > Is there a fix for this? Aside from using jack on a computer where it
>> > befnurgles the midi?
>> > -- next part --
>> > An HTML attachment was scrubbed...
>> > URL: <
>> http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200419/76d94eef/attachment-0001.html
>> >
>> >
>> > --
>> >
>> > ___
>> > chuck-users mailing list
>> > chuck-users@lists.cs.princeton.edu
>> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>> >
>> >
>> > End of chuck-users Digest, Vol 176, Issue 4
>> > ***
>>
>> ___
>> chuck-users mailing list
>> chuck-users@lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>
___
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users


Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-19 Thread Forrest Curo
Um. that works.
So does this:
SndBuf s => blackhole;
"/home/forrest/chuck/examples/basic/om.wav" => s.read;
float samples;
0 => int i;
while (s.pos() < s.samples())  {
<<< s.last() >>>;
s.pos() => i;
(s.valueAt(i)) => samples;
<<< samples >>>;
samp => now;
}

I was having trouble trying to read a sndBuf like an array, or put its
contents into an array.
Maybe I was reading numbers off the end of the file. Declaring
'float samples[]; '
and doing
's.valueAt(i) => samples[i];'

got me a 'Null pointer' error.

Stumbling over syntax, I guess. Thanks for help!

On Sun, Apr 19, 2020 at 10:54 AM Perry Cook  wrote:

> This is truly odd.  I don’t have easy means to test it.   I don’t
> know why it wouldbe broken dependent on the dac, however.
>
> For fun you might try something like this, just to verify that the
> valueAt() function is what’s busted.
>
> SndBuf s => blackhole;
> “Fred.wav” => s.read;
>
> while (s.pos() < s.samples())  {
> <<< s.last() >>>;
> samp => now;
> }
>
> PRC
>
> > On Apr 19, 2020, at 9:00 AM, chuck-users-requ...@lists.cs.princeton.edu
> wrote:
> >
> > Send chuck-users mailing list submissions to
> >   chuck-users@lists.cs.princeton.edu
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > or, via email, send a message with subject or body 'help' to
> >   chuck-users-requ...@lists.cs.princeton.edu
> >
> > You can reach the person managing the list at
> >   chuck-users-ow...@lists.cs.princeton.edu
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of chuck-users digest..."
> >
> >
> > Today's Topics:
> >
> >   1. sndBuf.valueAt (Forrest Curo)
> >
> >
> > --
> >
> > Message: 1
> > Date: Sun, 19 Apr 2020 07:30:15 -0700
> > From: Forrest Curo 
> > To: ChucK Users Mailing List 
> > Subject: [chuck-users] sndBuf.valueAt
> > Message-ID:
> >g...@mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Using chuck linux-jack this gives me reasonable numbers between -1 and 1.
> > Using chuck linux-alsa I'm able to play the file I've read into sndBuf;
> but
> > trying to copy it via .valueAt gives absurdly high ["out of range"]
> numbers
> > at each point. [It can be a different high number different times I run
> > chuck, but the number it is turns up at every point I sample.]
> >
> > Is there a fix for this? Aside from using jack on a computer where it
> > befnurgles the midi?
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL: <
> http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200419/76d94eef/attachment-0001.html
> >
> >
> > --
> >
> > ___
> > chuck-users mailing list
> > chuck-users@lists.cs.princeton.edu
> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> >
> >
> > End of chuck-users Digest, Vol 176, Issue 4
> > ***
>
> ___
> chuck-users mailing list
> chuck-users@lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
___
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users


Re: [chuck-users] sndBuf.valueAt (Forrest Curo asks)

2020-04-19 Thread Perry Cook
This is truly odd.  I don’t have easy means to test it.   I don’t 
know why it wouldbe broken dependent on the dac, however.

For fun you might try something like this, just to verify that the
valueAt() function is what’s busted.

SndBuf s => blackhole;  
“Fred.wav” => s.read;

while (s.pos() < s.samples())  {
<<< s.last() >>>;
samp => now;
}

PRC
 
> On Apr 19, 2020, at 9:00 AM, chuck-users-requ...@lists.cs.princeton.edu wrote:
> 
> Send chuck-users mailing list submissions to
>   chuck-users@lists.cs.princeton.edu
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> or, via email, send a message with subject or body 'help' to
>   chuck-users-requ...@lists.cs.princeton.edu
> 
> You can reach the person managing the list at
>   chuck-users-ow...@lists.cs.princeton.edu
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of chuck-users digest..."
> 
> 
> Today's Topics:
> 
>   1. sndBuf.valueAt (Forrest Curo)
> 
> 
> --
> 
> Message: 1
> Date: Sun, 19 Apr 2020 07:30:15 -0700
> From: Forrest Curo 
> To: ChucK Users Mailing List 
> Subject: [chuck-users] sndBuf.valueAt
> Message-ID:
>   
> Content-Type: text/plain; charset="utf-8"
> 
> Using chuck linux-jack this gives me reasonable numbers between -1 and 1.
> Using chuck linux-alsa I'm able to play the file I've read into sndBuf; but
> trying to copy it via .valueAt gives absurdly high ["out of range"] numbers
> at each point. [It can be a different high number different times I run
> chuck, but the number it is turns up at every point I sample.]
> 
> Is there a fix for this? Aside from using jack on a computer where it
> befnurgles the midi?
> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> 
> 
> --
> 
> ___
> chuck-users mailing list
> chuck-users@lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> 
> 
> End of chuck-users Digest, Vol 176, Issue 4
> ***

___
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users