

SAMPLE OSC (2)
--------------


WARNING: THIS MODULE IS OBSOLETE AND IS SCHEDULING FOR A REDO. IT WAS STILL COODED QUITE POORLY AND CAN STILL CONTAIN BUGS. PLEASE AVOID REPORTING BUGS !!!!



Full-featured sample oscillator to be used in conjunction with the Audio Recorder, Wav Sample Loader or other (future) suitable modules offering the same output BLOB sample format.

Supports three looping modes (once, loop, loop + end), ping-pong looping and variable-size loop crossfade for smooth loops or other creative effects.

There are no constrains as for where to place the sample start/end and loop positions. If Start is placed after End, the result will be backwards playing. A similar criterion applies to the loop markers. Reading outside the physical sample boundaries is always allowed and simply results in silence. No checks or corrections are internally done; you are therefore responsible to set meaningful values.

Spline (cubic) interpolation is always used to read samples from the sample buffer at fractional positions, to warrant high quality playback at very low pitches. No anti-alaising feature for playing at higher pitch (downsampling) is currently provided, being the present oscillator not conceived as a wavetable oscillator.

WARNING: when connecting Patch Memories Int to the four position pins, ALWAYS MAKE SURE TO SET A SUITABLY
         HIGH RANGE (eg. 100000000) and do not leave the default range of 10, otherwise serious problems can
         occur in the exported plugin !


SAMPLE PLAYBACK RATIONALE

 -Loop Mode = Once: playback is always carried from Start to End position.
 -Loop Mode = Loop: playback is carried from Start position to Loop *End* position, then playing
                    within Loop Start and Loop End indefinitely, either jumping from Loop End to Loop Start
                    or back and forth depending on the Ping Pong setting.
 -Loop Mode = Loop+End: playback is carried as above, with the exception that, on a Gate Off event,
                        playback will proceed from the current to the End position no matter what.

 -By specifying an End or Loop End position of -1, the respective End marker will be automatically placed
  at the physical sample end for convenience
 

LOOP CROSSFADE

 To warrant continuity at the loop junction points (unless Ping Pong is enabled, in which case
 no discontinuity can arise), a variable amount of samples *before* (play direction wise) the
 loop start position is used for a cross-fade towards the loop end position.
 When a cross fade amount of 1 (100%) is selected, the entire loop area will be affected by cross-fading.
 Therefore, always make sure there are enough samples before the loop start marker, otherwise silence will
 be picked making the cross-fading ineffective and in the worst case clicks may occur.
 For example, if the loop area is 1000 samples wide, an amount of .5 is specified and all markers are placed
 in sequence from left to right (Start, Loop Start, Loop End, End), you shall make sure that the loop start
 marker is not located before position 500. Similarly, if loop markers are placed backwards (loop end before
 loop start), you shall make sure that from the loop start marker to the physical sample end there are at
 least 500 samples left, or 1000 if cross fade amount is 1, and so on.
 If a Gate Off event is received while looping with cross-fade enabled in Loop Mode = Loop+End, the next and
 last loop will be played *without* crossfade, to preserve waveform continuity towards the end position.


PIN DESCRIPTION

 .Data In (Blob) - receives the sample data in standard ED BLOB sample format (32 bits Floats, raw data)

 .Gate - when >0 (Gate On) triggers playback; when <=0 (Gate Off) stops playback depending on the loop
         mode selected (see Loop Mode below)

 .Pitch - relative playback pitch in Octaves (0= original pitch, 1= 2x original pitch, and so on).

 .Original Rate (float) - to spare usage of external maths, the original sampling rate of the sample
                          in Hz (if any) can be specified here, to warrant playback consistency.
                          If zero is specified, no correction is done. Useful when importing samples
                          recorded with a different sampling rate than the currently used one.

 .Start (int) - sample start offset

 .End (int) - sample end offset (-1 means physical end of the sample)

 .Loop Start (int) - loop start marker

 .Loop End (int) - loop end marker

 .Loop XFade (float) - amount of loop area (0/1=100%) covered by crossfade. Active only when
                       Loop Mode = LOOP

 .Loop Mode (list) - Switch between the three supported loop modes:

                     ONCE - the sample will be played from the START to the END marker
                            (Gate Off events will be ignored)

                     LOOP - the sample will be played from the START marker to the LOOP START
                            marker, then looping forever between the LOOP START and LOOP END
                            markers (Gate Off events will be ignored)

                     LOOP+END - the sample will be played from the START marker to the LOOP START
                                marker, then looping between the LOOP START and LOOP END markers
                                until a Gate Off is received, continuing then from the current
                                position to the END marker

 .Loop Ping Pong (bool) - If enabled, sample playback between the Loop Start and Loop End markers
                          is performed back and forth (bouncing)

 .Off/On (list) - Switches the Sample Oscillator On or Off to spare CPU when not used

 .Output - oscillator audio output
                        
