jass.patches
Class LowpassColorSonificator

java.lang.Object
  extended by jass.engine.Out
      extended by jass.engine.InOut
          extended by jass.patches.LowpassColorSonificator
All Implemented Interfaces:
Sink, Source

public class LowpassColorSonificator
extends InOut

Map HSB color to [pitch reson-width lowpass-cutoff] Represent a color (h,s,b) by a noise source of maximum freq~b, filtered through a reson bank with Shepard frequencies (i.e. octaves apart covering the audible range) and some damping d = 1*freq/freq_lowest. The hue h [0 1] will be mapped to an octave range in freq. (Note the dampings are also scaled when freq. is scaled to preserve scale invariance of octaves.) The saturation s [0 1] will be mapped to the "material" (i.e., the width of the resonances will be multiplied by a factor depending on the saturation. This is a patch using ColorSonificator (with b==1) and then filter through Butterworth filter. So brightness is mapped to surface roughness if we think of the sound as being scrpe sounds.

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

Field Summary
protected  Butter2LowFilter butter2LowFilter
           
protected  FilterContainer filterContainer
           
protected  float lowerFreq
           
protected  float maxSlideVelocity
           
protected  float minSlideVelocity
           
protected  float srate
           
protected  jass.patches.LowpassColorSonificator.HS1ColorSonificator theHS1ColorSonificator
           
protected  float upperFreq
           
 
Fields inherited from class jass.engine.InOut
sourceContainer, sourcePassivity, srcBuffers
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld, lock
 
Constructor Summary
LowpassColorSonificator(float srate, int bufferSize)
          Create and initialize.
LowpassColorSonificator(int bufferSize)
          Create.
LowpassColorSonificator(int bufferSize, float srate)
          Create.
 
Method Summary
 java.lang.Object addSource(Source s)
          Add source to input of patch, the lowpass filter in this case.
protected  void computeBuffer()
          Compute the next buffer and store in member float[] buf.
protected  void createPatch()
           
 float getFudgePower(float p)
          Get power in scaling law for gains a = a*d^fudgePower.
 float[] getLowpassFrequencyRange()
          Get freq.
 void setFudgePower(float p)
          Set power in scaling law for gains a = a*d^fudgePower.
 void setHSB_V(float h, float s, float b, float v)
          Set hue, saturation, brightness and slide velocity (1 = max)
 void setHSB(float h, float s, float b)
          Set hue, saturation and brightness
 void setLowpassFrequencyRange(float lower, float upper)
          Set freq.
 void setSaturationLimits(float dmin, float dmax)
          Set damping range corresponding to saturation
 
Methods inherited from class jass.engine.InOut
addSource, getBuffer, getSources, removeSource, resetTime
 
Methods inherited from class jass.engine.Out
clearBuffer, copyToOld, getBuffer, getBufferSize, getTime, peekAtBuffer, setBufferSize, setTime, setTimeAndNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

srate

protected float srate

upperFreq

protected float upperFreq

lowerFreq

protected float lowerFreq

filterContainer

protected FilterContainer filterContainer

butter2LowFilter

protected Butter2LowFilter butter2LowFilter

theHS1ColorSonificator

protected jass.patches.LowpassColorSonificator.HS1ColorSonificator theHS1ColorSonificator

minSlideVelocity

protected float minSlideVelocity

maxSlideVelocity

protected float maxSlideVelocity
Constructor Detail

LowpassColorSonificator

public LowpassColorSonificator(float srate,
                               int bufferSize)
Create and initialize.

Parameters:
srate - sampling rate in Hertz.
bufferSize - Buffer size used for real-time rendering.

LowpassColorSonificator

public LowpassColorSonificator(int bufferSize)
Create. For derived classes.

Parameters:
bufferSize - Buffer size used for real-time rendering.

LowpassColorSonificator

public LowpassColorSonificator(int bufferSize,
                               float srate)
Create. For derived classes.

Parameters:
bufferSize - Buffer size used for real-time rendering.
srate - sampling rate in Hz
Method Detail

setLowpassFrequencyRange

public void setLowpassFrequencyRange(float lower,
                                     float upper)
Set freq. limits of lowpass

Parameters:
lower - freq for black
upper - freq. for white

getLowpassFrequencyRange

public float[] getLowpassFrequencyRange()
Get freq. limits of lowpass

Returns:
[lower upper] freq for black and white

setFudgePower

public void setFudgePower(float p)
Set power in scaling law for gains a = a*d^fudgePower. .5 for constant energy but lower in practice because of critical band effect, to have d-independent loudness

Parameters:
p - fudgePower

getFudgePower

public float getFudgePower(float p)
Get power in scaling law for gains a = a*d^fudgePower. .5 for constant energy but lower in practice because of critical band effect, to have d-independent loudness

Returns:
fudgePower

setSaturationLimits

public void setSaturationLimits(float dmin,
                                float dmax)
Set damping range corresponding to saturation

Parameters:
dmin - damping for saturated color
dmax - damping for unsaturated color

createPatch

protected void createPatch()

addSource

public java.lang.Object addSource(Source s)
                           throws SinkIsFullException
Add source to input of patch, the lowpass filter in this case. Allow 1 input only

Specified by:
addSource in interface Sink
Overrides:
addSource in class InOut
Parameters:
s - Source to add.
Returns:
object representing Source in Sink (may be null).
Throws:
SinkIsFullException

setHSB

public void setHSB(float h,
                   float s,
                   float b)
Set hue, saturation and brightness

Parameters:
h - hue in range 0-1
s - saturation in range 0-1
b - brightness in range 0-1

setHSB_V

public void setHSB_V(float h,
                     float s,
                     float b,
                     float v)
Set hue, saturation, brightness and slide velocity (1 = max)

Parameters:
h - hue in range 0-1
s - saturation in range 0-1
b - brightness in range 0-1
v - velocity in range 0-1

computeBuffer

protected void computeBuffer()
Compute the next buffer and store in member float[] buf.

Specified by:
computeBuffer in class Out