Hello. The StringTokenizer will preserve the comma (it looks to be hard-coded 
to separate at spaces) but it looks like Std.atof will ignore it.
<<< Std.atof( "100," ) >>>;

> 100.000000 :(float)
Here's a way to do those interpolating SinOscs:
/////////////////////////////
4 => int numOsc;
200::ms => dur rampSpeed;

SinOsc osc[numOsc];
Step st[numOsc];
Envelope freq[numOsc];
Envelope amp[numOsc];

Gain g => dac;
1.0 / numOsc => g.gain;

// initialize and connect oscillators
for (int i; i<numOsc; i++) {
st[i] => freq[i] => osc[i] => amp[i] => g;
1 => st[i].next; // need to send a 1 into the envelope to multiply freq values
rampSpeed => freq[i].duration => amp[i].duration;
}

while (true) {
for (int i; i<numOsc; i++) {
Math.random2f(200,800) => freq[i].target;
Math.random2f(0,1) => amp[i].target;
}
500::ms => now;
}

///////////////////////////
Sent from Mailspring 
(https://link.getmailspring.com/link/1528671165.local-350ae256-7699-v1.2.2-96fb3...@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=Y2h1Y2stdXNlcnNAbGlzdHMuY3MucHJpbmNldG9uLmVkdQ%3D%3D),
 the best free email app for work
On Jun 10 2018, at 5:15 pm, Stephen D Beck <sdb...@lsu.edu> wrote:
>
> This should be very easy. CSV files are common text files, with data 
> separated by commas, hence the name Comma-Separated-Values. I've never done 
> this before, but it seems like this would be pretty straight forward, and 
> something I should have done!
> Let us know how it works.
> Steve
> ________________________________________
> From: chuck-users-boun...@lists.cs.princeton.edu 
> <chuck-users-boun...@lists.cs.princeton.edu> on behalf of mario.buoninfante 
> <mario.buoninfa...@gmail.com>
> Sent: Sunday, June 10, 2018 5:08:55 PM
> To: Forrest; chuck-users
> Subject: Re: [chuck-users] New to ChucK: can this be done easily?
>
> Hi,
> I've never tried to use CSV files with ChucK, an alternative could be use a 
> common txt file with FileIO like you said.
> About the interpolation an easy way could be using Step and Envelope to set 
> both freq and amplitude of the oscillators.
>
> Cheers,
> Mario
>
> Sent from my Wiko ROBBY
> On Jun 10, 2018 22:35, Forrest Cahoon <forrest.cah...@gmail.com> wrote:
> Hi ChucKers!
>
> I have a sonification project that I'm wondering if it makes sense to do in 
> ChucK.
> I have a csv file with frequencies and amplitudes for 4 different sine waves, 
> representing values at (say) half-second intervals. I want to read in a line, 
> and then smoothly change the frequency and amplitude values using linear 
> interpolation over the course of 24000 samples (a half second at 48k samples 
> per second), then read in the next line, and smoothly change to those values 
> over the next half-second, etc. until the data runs out.
> I could code this in C using libsndfile, but if I didn't have to worry about 
> converting frequencies into phase distances between samples I'd consider that 
> a win.
> I noticed Chuck has FileIO methods to read input files (although these are 
> very poorly documented) so thought it should be possible to read in a csv 
> file.
> I could calculate the amount of frequency and amplitude change per sample and 
> adjust these in a 1-sample loop, and that's already simpler than coding in C. 
> But I'm hoping there's some way to tell ChucK "I want this (e.g. frequency) 
> value to change smoothly from its current value to f1 over the course of a 
> half-second". If that were possible, ChucK would be a clear choice for my 
> project.
> Thanks for any response!
> Forrest Cahoon
> _______________________________________________
> 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

Reply via email to