EZAudioPlotGL

Undocumented

  • Undocumented

  • Undocumented

  • The plot’s gain value, which controls the scale of the y-axis values. The default value of the gain is 1.0f and should always be greater than 0.0f.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) float gain;

    Swift

    var gain: Float { get set }
  • The type of plot as specified by the EZPlotType enumeration (i.e. a buffer or rolling plot type). Default is EZPlotTypeBuffer.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) EZPlotType plotType;

    Swift

    var plotType: EZPlotType { get set }
  • A BOOL indicating whether or not to fill in the graph. A value of YES will make a filled graph (filling in the space between the x-axis and the y-value), while a value of NO will create a stroked graph (connecting the points along the y-axis). Default is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL shouldFill;

    Swift

    var shouldFill: Bool { get set }
  • A boolean indicating whether the graph should be rotated along the x-axis to give a mirrored reflection. This is typical for audio plots to produce the classic waveform look. A value of YES will produce a mirrored reflection of the y-values about the x-axis, while a value of NO will only plot the y-values. Default is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL shouldMirror;

    Swift

    var shouldMirror: Bool { get set }
  • Updates the plot with the new buffer data and tells the view to redraw itself. Caller will provide a float array with the values they expect to see on the y-axis. The plot will internally handle mapping the x-axis and y-axis to the current view port, any interpolation for fills effects, and mirroring. - parameter: buffer A float array of values to map to the y-axis. - parameter: bufferSize The size of the float array that will be mapped to the y-axis.

    Declaration

    Objective-C

    - (void)updateBuffer:(float *)buffer withBufferSize:(UInt32)bufferSize;

    Swift

    func updateBuffer(_ buffer: UnsafeMutablePointer

    Parameters

    buffer

    A float array of values to map to the y-axis.

    bufferSize

    The size of the float array that will be mapped to the y-axis.

  • Sets the length of the rolling history buffer (i.e. the number of points in the rolling plot’s buffer). Can grow or shrink the display up to the maximum size specified by the maximumRollingHistoryLength method. Will return the actual set value, which will be either the given value if smaller than the maximumRollingHistoryLength or maximumRollingHistoryLength if a larger value is attempted to be set. - parameter: historyLength The new length of the rolling history buffer. - returns: The new value equal to the historyLength or the maximumRollingHistoryLength.

    Declaration

    Objective-C

    - (int)setRollingHistoryLength:(int)historyLength;

    Swift

    func setRollingHistoryLength(_ historyLength: Int32) -> Int32

    Parameters

    historyLength

    The new length of the rolling history buffer.

    Return Value

    The new value equal to the historyLength or the maximumRollingHistoryLength.

  • Provides the length of the rolling history buffer (i.e. the number of points in the rolling plot’s buffer). * - returns: An int representing the length of the rolling history buffer

    Declaration

    Objective-C

    - (int)rollingHistoryLength;

    Swift

    func rollingHistoryLength() -> Int32

    Return Value

    An int representing the length of the rolling history buffer

  • Clears all data from the audio plot (includes both EZPlotTypeBuffer and EZPlotTypeRolling)

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()
  • Call this method to tell the EZAudioDisplayLink to stop drawing temporarily.

    Declaration

    Objective-C

    - (void)pauseDrawing;

    Swift

    func pauseDrawing()
  • Call this method to manually tell the EZAudioDisplayLink to start drawing again.

    Declaration

    Objective-C

    - (void)resumeDrawing;

    Swift

    func resumeDrawing()
  • This method is used to perform the actual OpenGL drawing code to clear the background and draw the lines representing the 2D audio plot. Subclasses can use the current implementation as an example and implement their own custom geometries. This is the analogy of overriding the drawRect: method in an NSView or UIView. - parameter: points An array of EZAudioPlotGLPoint structures representing the mapped audio data to x,y coordinates. The x-axis goes from 0 to the number of points (pointCount) while the y-axis goes from -1 to 1. Check out the implementation of this method to see how the model view matrix of the base effect is transformed to map this properly to the viewport. - parameter: pointCount A UInt32 representing the number of points contained in the points array. - parameter: baseEffect An optional GLKBaseEffect to use as a default shader. Call prepareToDraw on the base effect before any glDrawArrays call. - parameter: vbo The Vertex Buffer Object used to buffer the point data. - parameter: vab The Vertex Array Buffer used to bind the Vertex Buffer Object. This is a Mac only thing, you can ignore this completely on iOS. - parameter: interpolated A BOOL indicating whether the data has been interpolated. This means the point data is twice as long, where every other point is 0 on the y-axis to allow drawing triangle stripes for filled in waveforms. Typically if the point data is interpolated you will be using the GL_TRIANGLE_STRIP drawing mode, while non-interpolated plots will just use a GL_LINE_STRIP drawing mode. - parameter: mirrored A BOOL indicating whether the plot should be mirrored about the y-axis (or whatever geometry you come up with). - parameter: gain A float representing a gain that should be used to influence the height or intensity of your geometry’s shape. A gain of 0.0 means silence, a gain of 1.0 means full volume (you’re welcome to boost this to whatever you want).

    Declaration

    Objective-C

    - (void)redrawWithPoints:(EZAudioPlotGLPoint *)points
                  pointCount:(UInt32)pointCount
                  baseEffect:(GLKBaseEffect *)baseEffect
          vertexBufferObject:(GLuint)vbo
           vertexArrayBuffer:(GLuint)vab
                interpolated:(BOOL)interpolated
                    mirrored:(BOOL)mirrored
                        gain:(float)gain;

    Swift

    func redraw(withPoints points: UnsafeMutablePointer

    Parameters

    points

    An array of EZAudioPlotGLPoint structures representing the mapped audio data to x,y coordinates. The x-axis goes from 0 to the number of points (pointCount) while the y-axis goes from -1 to 1. Check out the implementation of this method to see how the model view matrix of the base effect is transformed to map this properly to the viewport.

    pointCount

    A UInt32 representing the number of points contained in the points array.

    baseEffect

    An optional GLKBaseEffect to use as a default shader. Call prepareToDraw on the base effect before any glDrawArrays call.

    vbo

    The Vertex Buffer Object used to buffer the point data.

    vab

    The Vertex Array Buffer used to bind the Vertex Buffer Object. This is a Mac only thing, you can ignore this completely on iOS.

    interpolated

    A BOOL indicating whether the data has been interpolated. This means the point data is twice as long, where every other point is 0 on the y-axis to allow drawing triangle stripes for filled in waveforms. Typically if the point data is interpolated you will be using the GL_TRIANGLE_STRIP drawing mode, while non-interpolated plots will just use a GL_LINE_STRIP drawing mode.

    mirrored

    A BOOL indicating whether the plot should be mirrored about the y-axis (or whatever geometry you come up with).

    gain

    A float representing a gain that should be used to influence the height or intensity of your geometry’s shape. A gain of 0.0 means silence, a gain of 1.0 means full volume (you’re welcome to boost this to whatever you want).

  • Called during the OpenGL run loop to constantly update the drawing 60 fps. Callers can use this force update the screen while subclasses can override this for complete control over their rendering. However, subclasses are more encouraged to use the redrawWithPoints:pointCount:baseEffect:vertexBufferObject:vertexArrayBuffer:interpolated:mirrored:gain:

    Declaration

    Objective-C

    - (void)redraw;

    Swift

    func redraw()
  • Called after the view has been created. Subclasses should use to add any additional methods needed instead of overriding the init methods.

    Declaration

    Objective-C

    - (void)setup;

    Swift

    func setup()
  • Main method used to copy the sample data from the source buffer and update the plot. Subclasses can overwrite this method for custom behavior. - parameter: data A float array of the sample data. Subclasses should copy this data to a separate array to avoid threading issues. - parameter: length The length of the float array as an int.

    Declaration

    Objective-C

    - (void)setSampleData:(float *)data length:(int)length;

    Swift

    func setSampleData(_ data: UnsafeMutablePointer

    Parameters

    data

    A float array of the sample data. Subclasses should copy this data to a separate array to avoid threading issues.

    length

    The length of the float array as an int.

  • Provides the default length of the rolling history buffer when the plot is initialized. Default is EZAudioPlotDefaultHistoryBufferLength constant. - returns: An int describing the initial length of the rolling history buffer.

    Declaration

    Objective-C

    - (int)defaultRollingHistoryLength;

    Swift

    func defaultRollingHistoryLength() -> Int32

    Return Value

    An int describing the initial length of the rolling history buffer.

  • Provides the default maximum rolling history length - that is, the maximum amount of points the setRollingHistoryLength: method may be set to. If a length higher than this is set then the plot will likely crash because the appropriate resources are only allocated once during the plot’s initialization step. Defualt is EZAudioPlotDefaultMaxHistoryBufferLength constant. - returns: An int describing the maximum length of the absolute rolling history buffer.

    Declaration

    Objective-C

    - (int)maximumRollingHistoryLength;

    Swift

    func maximumRollingHistoryLength() -> Int32

    Return Value

    An int describing the maximum length of the absolute rolling history buffer.