grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

soundfile library #363

Closed dblanchemain closed 4 years ago

dblanchemain commented 4 years ago

In these lines

length(sf, part) = (part, 0) : sf : (_,si.block(outputs(sf)-1)); 

 srate(sf, part) = part, 0 : sf : !,_,si.block(outputs(sf)-2) : float;

 outs(sf, level) = sf : si.block(2), bus(outputs(sf)-2) with { bus(n) = par(i,n,*(level)); };

what is the difference and meaning of these writings (part, 0) and part, 0 on the second line?

Why does the player only offer 2 read channels width jack ?

'reader' in a function of type \(sf,part).(body) whih produces the (possibly fractional) read index

 player(sf, part, reader, level) = (part, ru.int_part(reader(sf, part))) : outs(sf, level);

My files have 8 or 6 channels and I only have 2 outputs.

sletz commented 4 years ago

Can you paste the exact DSP code your are writing to load your soundfiles?

dblanchemain commented 4 years ago

here is the code

declare name        "player";
declare version     "1.0";
declare author      "Grame";
declare license     "BSD";
declare copyright   "(c)GRAME 2006";

declare options "[midi:on][nvoices:12]";

import("stdfaust.lib");
import("soundfiles.lib");

ds1=soundfile("[url:{'Coagula03c6.wav';'Coagula13-2.wav';'Coagula00c8.wav'}]",2);
ds2=soundfile("[url:{'home/dominique/bin/metaLoop9/sound/snd1.wav';'home/dominique/bin/metaLoop9/sound/snd2.wav'}]",2); 

pitchshifter = vgroup("Pitch Shifter", ef.transpose(
                                    hslider("window (samples)", 1000, 50, 10000, 1),
                                    hslider("xfade (samples)", 10, 1, 10000, 1),
                                    hslider("shift (semitones) ", 0, -12, +12, 0.1)
                                  )
                );      

sl = vslider("Signal[style:menu{'Liste1':0;'Liste2':1}]",0,0,1,1);
s1=ds1;
sample1 = so.sound(s1, 0);
sample2 = so.sound(s1, 1);
sample3 = so.sound(s1, 2);

//sample1.loop;
//sample1.loop_speed(0.5);
//sample1.loop_speed_level(0.5, 0.5);
//sample3.play(0.5, button("gate"));

gain = hslider("gain[midi:keyon 62]",0.1,0,1,0.01);

gate = button("gate[midi:key 62]");
envelope = en.adsr(0.01,0.04,0.8,0.1,gate)*gain;

gain2 = hslider("gain2[midi:keyon 60]",0.1,0,1,0.01);

gate2 = button("gate2[midi:key 60]");
envelope2 = en.adsr(0.01,0.04,0.8,0.1,gate2)*gain2;

process = sample1.play(envelope, gate),sample2.play(envelope2, gate2);

I have 2 channels per sample while the first file has 6 channels, 2 em 2 and 3em 8 channels.

this code and just for a test

dblanchemain commented 4 years ago

Is it possible to choose a sound bank for s1, ds1 or ds2 for example for this code and how?

sletz commented 4 years ago

Read the soundfile documentation again here: https://faust.grame.fr/doc/manual/index.html#soundfile-primitive

In the soundfile primitive, the last argument is the number of channels that you want. If more outputs than the actual number of channels in the sound file are used, the audio channels will be automatically duplicated up to the wanted number of outputs (so for instance, if a stereo file is used with four output channels, the same group of two channels will be duplicated). So if you have a soundile with 6 channels you'll have to write something like:

ds1=soundfile("[url:{'Coagula03c6.wav';'Coagula13-2.wav';'Coagula00c8.wav'}]",6);

and so on for the 8 channels case.

dblanchemain commented 4 years ago

thank you so much