Class
TkCanvas
In: rbSnack/tkSnack.rb
Parent: Object

An extension of the standard TkCanvas class, used as an easy way to display waveforms, spectorgrams and spectrum sections

Methods

attachSection, attachSpectrogram, attachWaveform,
Public Instance methods
attachWaveform(snd, x=0, y=0, options=nil, &op_block) src

Attaches a waveform of a specified sound to this canvas. The first argument, snd, specifes the sound object.The integers x and y are the upper lefthand coordinates of the display Options can be any of the following

anchor anchorPos
Specifies the anchor positon on the canvas
channel channel
Selects the channels.For 2 channel system: -1, means both; 0 is left, 1 is right. Default is -1.
stop endPos
Specifies the ending position of the sample to be display
fill fillColor
Specifies the fill color
frame boolean
Determines whether the display is to be framed: true means a frame is drawn about the section, false means no frame and is the default.
height height
Specifies the height of the waveform
limit maxAmplitude
Specifies the maximum amplitude to be displayed
pixelspersecond pps
Is the number of horizontal pixels representing one second of elapsed time.
progress cmd
Specifies a callback procedure: NOT IMPLEMENTED YET!
shapefile fileName
Specifies the filename of a file for storing/retrieving precomputed waveform shape information. Used for speeding up display.
start startPos
Specifies the starting position of the sample to be display
stipple bitmap
Specifies bitmap for stipple.
subsample timeStepsPerPoint
Specifies the number of time steps between the points used for the generation of the waveform envelope. The default is 1, which gives the most faithful rendering, but is the slowest. Higher numbers will give quicker results, but risk degradation of the resulting waveform.
tags tagList
Specifies tag list
width width
Specifies the width of the waveform
zerolevel boolean
Determines whether to draw horizontal axis. The default value is true, which produces a horizontal line indicating 0 amplitude.

See also Sound# waveform_to_canvas

attachSpectrogram(snd, x=0, y=0, options=nil, &op_block) src

Attaches a spectrogram of a specified sound to this canvas. The first argument, snd, specifes the sound object.The integers x and y are the upper lefthand coordinates of the display Options can be any of the following

brightness brightness
Determines the brightness, must be chosen from the range of [-100, 100]. The default is 0.
channel channel
Selects the channels.For 2 channel system: -1, means both; 0 is left, 1 is right. Default is -1.
colormap colormap
Specifies a list of colors to determine the intesity. If the list is non-empty, it must have at least 2 colors, which will be interpreted as lowest to highest. The default is an empty list means produces a 32-level grey-scale display.
contrast contrast
Determines the contrast, must be chosen from the range of [-100, 100]. The default is 0.
stop endPos
Specifies the ending position of the sample to be display
fftlength no_fft_pts
Specifies the number of FFT points must be one of the values 8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096. Default is 512.
gridcolor gridcolor
Specifies the color of the grid
gridfspacing gridfreqspacing
Specifies the spacing along the frequency axis value (in Hz) The default is 0, ie. no grid
gridtspacing gridtimespacing
Specifies the spacing along the time axis (in milliseconds) The default is 0, ie. no grid
height height
Specifies the height of the spectrogram
pixelspersecond pps
Specifies the number of horizontal pixels representing one second of elapsed time.
preemphasisfactor factor
Specifies the amount of preemphasis applied to the signal prior to the FFT calculation, the default 0.97.
start startPos
Specifies the starting position of the sample to be display
tags tagList
Specifies atagList for the canvas
topfrequency maxFreq
Specifies the maximum frequency of spectrogram. Default is the Nyquist
width width
Specifies the width of the spectrogram. Maximum of 32767 pixels.
windowtype type
Specifies thetype of windowing function: must be one of the choices: Hamming, Hanning, Bartlett, Blackman, or Rectangle. The default is Hamming.
winlength size
Specifies size of the (hamming) window, it is required to be no greater than fftlength Note the default is 128

See also Sound# spectrogram_to_canvas

attachSection(snd, x=0, y=0, options=nil, &op_block) src

Attaches a FFT log power spectrum section of specified sound to this canvas. The first argument, snd, specifes the sound object.The integers x and y are the upper lefthand coordinates of the display Options can be any of the following

analysistype analysistype
Permissible values are: either FFT (default) or LPC
channel channel
Selects the channels.For 2 channel system: -1, means both; 0 is left, 1 is right. Default is -1.
stop endPos
Specifies the ending position of the sample to be display
fftlength fftlength
Specifies the number of FFT points must be one of the values 8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096. Default is 512.
fill fillColor
Specifies the fill color
frame boolean
Is a boolean value, where true means a frame is drawn about section, false means no frame and is the default.
height height
Specifies the height of section
lpcorder order
Specifies the lpc order when the analysis type is LPC. The default value is 20
maxvalue max_dB
Specifies the max dB displayed. Default is 0.0
minvalue min_dB
Specifies the min dB displayed. Default is -80.0
preemphasisfactor factor
Specifies the amount of preemphasis applied to the signal prior to the FFT calculation, the default 0.0.
skip no_of_skip_points
specifies how many points to move the window forward at each step
start startPos
Specifies the starting position of the sample to be display
stipple bitmap
Specifies the bitmap for stipple
tags tagList
Specifies the tagList for canvas
topfrequency topFreq
Specifies the frequency at the right end of the section
width width
Specifies the width of section
windowtype type
Specifies the type of windowing function: must be one of the choices: Hamming, Hanning, Bartlett, Blackman, or Rectangle. The default is Hamming.
winlength size
Specifies the size of the (hamming) window, it is required to be no greater than fftlength Note the default is 128

See also Sound# section_to_canvas