Class TutorialOne_06_WindowBuffer

java.lang.Object
processing.core.PApplet
net.paulhertz.pixelaudio.example.TutorialOne_06_WindowBuffer
All Implemented Interfaces:
processing.core.PConstants

public class TutorialOne_06_WindowBuffer extends processing.core.PApplet

TutorialOne_06_WindowBuffer

A continuation of TutorialOne_03_Drawing that keeps the drawing, brush, sampler, granular, bounds, and envelope code from TutorialOne_03_Drawing, but changes the audio source model to load large audio files into a windowed buffer:
  • anthemSignal / anthemBuffer hold the entire loaded audio file,
  • windowBuff is a moving window over anthemSignal,
  • audioSignal / playBuffer / mapImage hold only the current visible window,
  • Display coordinates map first to the visible window, then to the backing full-file source by adding windowBuff.getIndex().

The new features are fit on top of Tutorial_03_Drawing variables and methods. Support for WindowedBuffer is flagged with "// *** WindowedBuffer support *** //". Look for the flag to how TutorialOne_03_Drawing was adapted. See Tutorial_03_Drawing for information about drawing, audio synthesis, audio events and animation. Here we'll document just the new features.

See TutorialOne_03_Drawing

NEW FEATURES

This sketch adds a windowed audio buffer to the drawing, interaction and audio synthesis tools of TutorialOne_03_Drawing. A windowed audio buffer combines an audio buffer with a method that positions a "window" within a larger source or "backing" buffer and reads data from it to a separate data structure. TutorialOne_06_WindowBuffer uses PixelAudio's WindowedBuffer class to store a backing buffer read from an audio file. It uses the backing buffer as the source array for the smaller audio buffers audioSignal and playBuffer. We can use the window function to select which portion of the backing buffer we want to see and interact with. Data in audioSignal is transcoded as pixel values in mapImage, an image used in this sketch to provide a visual representation of the data in the audio buffer. A PixelAudioMapper instance, mapper, handles the mapping of data between image and audio structures, and also maps mouse interactions on the display image to sample indices in the audio buffer.

The Granular and Sampler instruments both use the backing audio buffer directly as their audio source, though they can also use the smaller audio buffers derived from the window function. The window that moves through the backing buffer is exactly the same size as the display image and the smaller audio buffers. It can be positioned anywhere within the backing buffer. It also can be automatically moved across the backing buffer at a specified rate, animating the display image.

Interaction with the sketch using the mouse and keyboard takes into account the indexing of the windowed audio buffer. A mouse click on the display image will trigger a sound from the sampler or granular instrument by requesting a sample index from mapper and adding the current window index in the backing buffer to it, thus obtaining the correct sample index in the backing buffer to forward to the instrument. It is possible to animate mapImage by pixel-shifting, which shifts the audio index with respect to the number of pixels shifted. Probably you won't want to run pixel-shifting and automatic window advancing together, but is is possible. As with the window index, the pixel shift index will be used to determine the audio sample index.

QUICK START

  1. Run the sketch. It will load the audio file specified in daPath and daFile, and write it to the display image as colors overlaid on a visualization of the audio values along the signal path. You can change the file with the 'o' key command.
  2. The drawing and audio synthesis features are the same as in TutorialOne_03_Drawing, but now mouse interactions will trigger audio events based on the current position of the windowed buffer within the backing buffer. You can trigger audio events at different locations in the audio file by moving the window and clicking on the display image.
  3. Press spacebar or click to trigger audio events at audio index corresponding to the mouse location. Draw brushstrokes for both Sampler and Granular events.
  4. Press 'T' to toggle automatic window advancement. Press '{' or '}' to jump back/forward one full window. Press '(' or ')' to jump back/forward one half window. Press 'R' to rewind the WindowBuffer.
  5. Press 'Y' to toggle raindrop point events while windowing.
  6. Experiment with drawing brushstrokes and triggering audio events while moving through the buffer.
 Here are the key commands for this sketch:
 
 Press UP ARROW to increase audio gain by 3 dB.
 Press DOWN ARROW to decrease audio gain by 3 dB.
 Press RIGHT ARROW to increase Sampler audio gain by 3 dB.
 Press LEFT ARROW to decrease Sampler audio gain by 3 dB.
 Press SHIFT-RIGHT ARROW to increase Granular audio gain by 3 dB.
 Press SHIFT-LEFT ARROW to decrease Granular audio gain by 3 dB.
 Press ' ' (spacebar) to trigger a brush if we're hovering over a brush, otherwise trigger a point event.
 Press '1' to set brushstroke under cursor to PathMode ALL_POINTS.
 Press '2' to set brushstroke under cursor to PathMode REDUCED_POINTS.
 Press '3' to set brushstroke under cursor to PathMode CURVE_POINTS.
 Press 't' to set brushstroke under cursor to use Sampler or Granular synth.
 Press 'f' to set brushstroke under cursor to FIXED hop mode for granular events.
 Press 'g' to set brushstroke under cursor to GESTURE hop mode for granular events.
 Press 'y' to select granular or sampler synth for click response.
 Press 'r' to select long or short grain duration .
 Press 'b' to toggle between long burst grains and short burst grains.
 Press 'p' to jitter the pitch of granular gestures.
 Press 'P' to adjust pitch of current brushstroke.
 Press '>' or '.' to increment epsilon value of current brush (reduced points decrease).
 Press '<' or ',' to decrement epsilon value of current brush (reduced points increase).
 Press ']' to increment curve steps value of current brush.
 Press '[' to decrement curve steps value of current brush.
 Press 'm' to change the Sampler noise reduction profile.
 Press 'e' to change the envelope we're using .
 Press 'E' to toggle whether we adjust envelope duration in relation to gesture duration.
 Press 'a' to  start or stop animation (bitmap rotation along the signal path).
 Press 'd' to toggle play audio on new brush .
 Press 'c' to apply color from image file to display image.
 Press 'k' to apply the hue and saturation in the colors array to mapImage (not to baseImage).
 Press 'K' to apply hue and saturation in colors to baseImage and mapImage.
 Press 'j' to turn audio and image blending on or off.
 Press 'n' to normalize the audio buffer to -6.0dB.
 Press 'L' or 'l' to determine whether to load a new file to both image and audio or not.
 Press 'o' or 'O' to open an audio or image file and load to image or audio buffer or both.
 Press 's' to save display image to a PNG file.
 Press 'S' to save audio buffer to a .wav file.
 Press 'w' to write the image HSB Brightness channel to the audio buffer as transcoded sample values .
 Press 'W' to write the audio buffer samples to the image as color values.
 Press 'x' to delete the current active brush shape or the oldest brush shape.
 Press 'X' to delete the most recent brush shape.
 Press 'u' to mute audio.
 Press 'V' to record a video.
 Press 'h' or 'H' to show help message in the console.

 WindowBuffer additions:
 Press 'T' to toggle automatic WindowBuffer traversal.
 Press '{' or '}' to jump back/forward one full window.
 Press '(' or ')' to jump back/forward one half window.
 Press 'R' to rewind the WindowBuffer.
 Press 'Y' to toggle raindrop point events while windowing.
 
REVISIONS