Audio 从Chuck中的文件读取int
我有一个ChucK代码:Audio 从Chuck中的文件读取int,audio,chuck,Audio,Chuck,我有一个ChucK代码: "examples/vento.txt" => string filename; FileIO fio; // open a file fio.open(filename, FileIO.READ); // ensure it's ok if(!fio.good()) { cherr <= "can't open file: " <= filename <= " for reading..." <= IO.newline();
"examples/vento.txt" => string filename;
FileIO fio;
// open a file
fio.open(filename, FileIO.READ);
// ensure it's ok
if(!fio.good()) {
cherr <= "can't open file: " <= filename <= " for reading..." <= IO.newline();
me.exit();
}
fio.readLine() => string velocity;
fio.readLine() => string direction;
(每分钟用python更新一次)
我想将速度和方向转换为int(或更好的浮点)
如何执行此操作?在
Std
库中使用atoi
和atof
。假设您希望从0-127(MIDI速度)转换为介于0和1.0之间的浮点(单位生成器更方便):
打印10.000000:(浮点)
10
12
Std.atoi(fio.readLine()) => int midi_velocity;
midi_velocity/127.0 => float velocity;
<<< velocity >>>;
Std.atof(fio.readLine()) => float velocity;
<<< velocity >>>;