Sampling in wcnt means reading from an audio file so its contents can be used in the same way as the output from any other module. This is done by using a data object called a wavfilein and the sampler module which uses it.
The sampler module has various abilities. These include triggers to start and stop its playback, modulation of the point playback is started from, and the ability to playback at different sample rates and automatic samplerate conversion. Playback is also linear interpolated for playback at lower frequencies than the samples natural rate.
It can play forward or backwards, and can loop in these directions also, aswell as bi-directional looping. The loop points can be set to be relative to the start point and for this, special parameters specifiy what to do when playback initially travels away from the loop.
The sampler can also be set to try to minimise pops from jumps in position, for example while it is playing and is retriggered, or during looping.
Finally it can also be told to ignore frequency changes altogether, react slightly to them, or exagerate them.
The wavfilein data object simply states the path and filename of the 16 bit WAV format audio file to use, and the root_note. The root_note parameter states for which note in the musical scale the sample should be played at it's natural playback rate.
If you increase the root_note by an octave to c1, then when it is played back at the frequency of the note c0 it plays back at half speed, half the frequency.
The sampler module is not particularly straight forward to use, but is flexible in it's functionality. Here is it's definition as supplied by wcnt's command line help.
The outputs, out_left and out_right output the 16 bit sample values of the .wav. out_l and out_r output the sample as floating point values between -1.0 and 1.0. Generally the floating point output of the sampler is the more usefull as this can be processed by other modules to do all manner of things to it. The 16 bit output can only be placed in a mix_chan or fed directly into a wavfile_out.
in_play_trig, regardless of the sampler already playing, triggers playback from the start position. The start position is determined by the value provided by in_start_pos_mod and the start_pos parameters. The value provided by in_start_pos_mod should ideally be in the range of 0.0 to 1.0 but negative values are flipped to positive, and values outside the range are taken as 0.0 and 1.0.
in_play_trig modulename outputname
The two start_pos parameters are the minimum and maximum sample positions within the sample that playback may start from. When in_start_pos_mod gives 0.0 playback starts from start_pos_min and 1.0 starts playback from start_pos_max. Sample positions longer than the sample length are set to the length of audio in the wavfilein.
You can use wcnt's command line help option to display the length in samples of a .wav file. The option -si is the short form of --sample-info.
wcnt -si somesample.wav
It is not necessary to connect in_stop_trig to a module output and is easier to set off. When it is used, the sampler will stop playback immediately when it triggers. This may be undesirable depending on how you use the sampler output and which module output you use to stop playback. It is provided to minimise processing when unnecessary.
The sampler has several parameters for setting up a playback loop within the .wav sample. The first loop parameter is loop_mode, which can be set to fwd for forward looping, rev for reverse, and bi for bi-directional. loop_start_pos, and loop_end_pos are the loop points within the sample.
The parameter loop_is_offset is either on or off. It can be set to on in conjunction with modulatable playback starting points, so that the loop points are added to the start point derived from the in_start_pos_mod input.
The possibility that playback may travel away from the loop is tackled with two more parameters which are only used when the sampler is set to loop. The first is play_mode and specifies what to do when playback arrives at the beginning or end of the sample before it arrives at the loop points. The settings are stop, wrap, bounce, and jump. wrap starts from the end if it reaches the beginning, and the beggining if it reaches the end. bounce means change playback direction, and jump means jump to the loop. The second parameter, jump_mode only applies when play_mode is jump and specifies the direction which to initially start the loop playing. This can either be set to playback in the play direction, or the loop direction.
Anyone who has used a basic sampler will have got frustrated trying to set loop points which do not click. wcnt's sampler has three methods which can be used together to minimise clicking from sudden jumps in playback. This can be when the sampler retriggers playback aswell as when it starts looping, or changes direction.
The first of these parameters is bi_directional_offset and is only used when playback changes direction. It specifies the number of samples to jump at the point playback direction changes. This is in order for the sampler to lessen the mirror effect of the waveform's phase a change in direction has, which can also cause a small click. It is most useful for samples containing uniform waveforms which are to contain bi-directional loops.
Generally waveforms have a positive and negative phase and these alternate. If you get two of the same phases following each other when they have previously been alternating, it sounds bad.
The second way the sampler attempts to smooth jumps in playback is to carry on playing from the point it has jumped from, but fade it out while fading in playback from the point it has jumped to. The length of the fades are specified in samples by the anti_clip_samples parameter. The fades are not normally performed at the start and end of the sample but the parameter anti_clip_each_end can be used to alter this. When set to on there is the slight drawback that that amount of samples is lost from each end of the file - except as they are faded in or out.
Finally zero_search_range sets the number of samples the sampler will search around the start point and loop points for zero amplitude samples in the audio and adjust the points accordingly. Quite often it will not be able to find a zero amplitude sample in the given range and in that case it will search for the next best thing.
The final sampler parameter is degsize_amount and controls how much notice to take of in_deg_size. A value of 0.0 will only ever playback the sample at it's natural rate. A value of 1.0 will treat values from in_deg_size as normal, and values greater than 1.0 will exagerate it. Values between 0.0 and 1.0 can be used for microtonal scales.
out_loop_trig triggers whenever the sampler reachs the bounds of the loop, and out_play_state is self explanatory.