jass.generators
Class CrossfadeLoopBuffer

java.lang.Object
  extended by jass.engine.Out
      extended by jass.generators.CrossfadeLoopBuffer
All Implemented Interfaces:
Source

public class CrossfadeLoopBuffer
extends Out

Provide a pitch shiftable object built of a set of recordings at particular frequencies. At any given freq. the sound is produced by pitch shifting nearby samples to this ranges and mixing them. If f is the disired freq. we find the two samples y1,2 with freq. f1 and f2 s.t. f1 < f < f2 . Both y1 and y2 are pitch shifted to f and then combined as y = (1-t)*y1_shifted + t*y2_shifted with 0

Author:
Kees van den Doel (kvdoel@cs.ubc.ca)

Field Summary
protected  float aLeft
           
protected  int dixLeft
          Current integer f of pointer in buffer per sample.
protected  int dixRight
          Current integer f of pointer in buffer per sample.
protected  float dxLeft
          Current fractional f [0 1] of pointer in buffer per sample.
protected  float dxRight
          Current fractional f [0 1] of pointer in buffer per sample.
protected  float f
          Loop f (frequency) through buffer.
protected  float[] fb
          Natural loop frequencies of buffers
protected  float[] gainCorrection
          fGAin corrections (1 if audio files are ok)
protected  int iLeft
           
protected  int ixLeft
          Current integer position of pointer in buffer.
protected  int ixRight
          Current integer position of pointer in buffer.
protected  float levelCorrection
           
protected  float[][] loopBuffer
          Array of buffers to loop
protected  int[] loopBufferLength
          Buffer lengths
protected  int nChannels
           
protected  float oldF
           
protected  float[] qFactor
           
 float srate
          Sampling rate in Hertz of Out.
 float srateLoopBuffer
          Sampling rate in Hertz of loaded buffers (must all be the same).
protected  float volume
          Playback volume.
protected  float xLeft
          Current fractional position [0 1] of pointer in buffer.
protected  float xRight
          Current fractional position [0 1] of pointer in buffer.
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld, lock
 
Constructor Summary
CrossfadeLoopBuffer(float srate, int bufferSize, java.lang.String[] fn, float[] fb)
          Construct buffers from named files.
CrossfadeLoopBuffer(int bufferSize)
          For derived classes
 
Method Summary
protected  void calcRates(float f)
           
 void computeBuffer()
          Compute the next buffer.
 ControllerPanel getControlPanel()
           
 ControllerPanel getEditorPanel(java.lang.String name)
           
 int getNChannels()
           
protected  float getNextSample(int k, int bufsz)
          Get next sample value, interpolating in between sample points.
protected  float getNextSampleStereo(int k, int bufsz)
           
 float getQ(int k)
           
static void main(java.lang.String[] args)
           
 void setF(float f)
          Set loopspeed.
 void setQ(int k, float val)
           
 void setVolume(float val)
          Set force magnitude.
 
Methods inherited from class jass.engine.Out
clearBuffer, copyToOld, getBuffer, getBuffer, getBufferSize, getTime, peekAtBuffer, resetTime, setBufferSize, setTime, setTimeAndNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loopBuffer

protected float[][] loopBuffer
Array of buffers to loop


loopBufferLength

protected int[] loopBufferLength
Buffer lengths


gainCorrection

protected float[] gainCorrection
fGAin corrections (1 if audio files are ok)


volume

protected float volume
Playback volume.


f

protected float f
Loop f (frequency) through buffer.


oldF

protected float oldF

fb

protected float[] fb
Natural loop frequencies of buffers


xLeft

protected float xLeft
Current fractional position [0 1] of pointer in buffer.


xRight

protected float xRight
Current fractional position [0 1] of pointer in buffer.


ixLeft

protected int ixLeft
Current integer position of pointer in buffer.


ixRight

protected int ixRight
Current integer position of pointer in buffer.


dxLeft

protected float dxLeft
Current fractional f [0 1] of pointer in buffer per sample.


dxRight

protected float dxRight
Current fractional f [0 1] of pointer in buffer per sample.


dixLeft

protected int dixLeft
Current integer f of pointer in buffer per sample.


dixRight

protected int dixRight
Current integer f of pointer in buffer per sample.


aLeft

protected float aLeft

levelCorrection

protected float levelCorrection

qFactor

protected float[] qFactor

iLeft

protected int iLeft

srate

public float srate
Sampling rate in Hertz of Out.


srateLoopBuffer

public float srateLoopBuffer
Sampling rate in Hertz of loaded buffers (must all be the same).


nChannels

protected int nChannels
Constructor Detail

CrossfadeLoopBuffer

public CrossfadeLoopBuffer(int bufferSize)
For derived classes

Parameters:
bufferSize - biffer size

CrossfadeLoopBuffer

public CrossfadeLoopBuffer(float srate,
                           int bufferSize,
                           java.lang.String[] fn,
                           float[] fb)
Construct buffers from named files.

Parameters:
srate - sampling rate in Hertz.
bufferSize - bufferSize of this Out
fn - Audio files names.
natural - frequencies of the audio files.
Method Detail

getQ

public float getQ(int k)

setQ

public void setQ(int k,
                 float val)

getNChannels

public int getNChannels()

setVolume

public void setVolume(float val)
Set force magnitude.

Parameters:
val - Volume.

setF

public void setF(float f)
Set loopspeed.

Parameters:
f - Loop freq.

calcRates

protected void calcRates(float f)

getNextSampleStereo

protected float getNextSampleStereo(int k,
                                    int bufsz)

getNextSample

protected float getNextSample(int k,
                              int bufsz)
Get next sample value, interpolating in between sample points.


computeBuffer

public void computeBuffer()
Compute the next buffer.

Specified by:
computeBuffer in class Out

getEditorPanel

public ControllerPanel getEditorPanel(java.lang.String name)

getControlPanel

public ControllerPanel getControlPanel()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception