Copyright © 2006-2019 MultiMedia Soft

WaveformAnalyzer.PeaksBufferGet method

Previous pageReturn to chapter overviewNext page

Remarks

 

Fills two buffers with min and max waveform peaks for the given range. The size of each buffer can be obtained with a previous call to the WaveformAnalyzer.PeaksBufferLengthGet method.

 

Before calling this method it's mandatory performing a previous sound's analysis through a call to the WaveformAnalyzer.AnalyzeFullSound method and waiting its completion through the WaveAnalysisDone event.

 

For details about the use of the Waveform Analyzer refer to the How to use the Waveform Analyzer section.

For further details about methods of the Waveform Analyzer refer to the WaveformAnalyzer class section.

 

 

Syntax

 

[Visual Basic]

Public Function PeaksBufferGet (

nChannel as Int16,

nStartPos as Int32,

nEndPos as Int32,

bValueInPerc as Boolean,

pBufferMin() as Int16,

pBufferMax() as Int16,

nBufferLength as Int32

) as enumErrorCodes


 

[C#]

public enumErrorCodes PeaksBufferGet (

Int16 nChannel,

Int32 nStartPos,

Int32 nEndPos,

bool bValueInPerc,

Int16[] pBufferMin,

Int16[] pBufferMax,

Int32 nBufferLength

);


 

[C++]

public: enumErrorCodes PeaksBufferGet (

Int16 nChannel,

Int32 nStartPos,

Int32 nEndPos,

bool bValueInPerc,

Int16 __gc[] pBufferMin,

Int16 __gc[] pBufferMax,

Int32 nBufferLength

);


 

 

Parameter

Description

 

 

nChannel

Number representing the audio channel we are interested in. Can be a value between 0 and 7.

nStartPos

Number representing the start position, expressed in milliseconds, where we want to get waveform's peaks.

The value 0 represents the sound's beginning.

nEndPos

Number representing the end position, expressed in milliseconds, where we want to get waveform's peaks.

The value -1 represents the sound's end.

bValueInPerc

Boolean value that specifies if the given buffers should be filled with values expressed in percentage.

Supported values are the following:

Mnemonic constant

Value

Meaning

BOOL_FALSE

0

Given buffers will be filled with values from 0 to 32767 for the pBufferMax buffer and from 0 to -32768 for the pBufferMin buffer.

BOOL_TRUE

1

Given buffers will be filled with values expressed in percentage

pBufferMin

Variant parameter containing the pointer to the buffer that, on return from the method call, will contain the min waveform peaks.

pBufferMax

Variant parameter containing the pointer to the buffer that, on return from the method call, will contain the max waveform peaks.

nBufferLength

Length in bytes of the given buffers previously obtained through the Waveform.PeaksBufferLengthGet method.

 

Return value

 

Value

Meaning

 

 

Negative value

An error occurred (see the LastError property for further error details)

enumErrorCodes.NOERROR (0)

The method call was successful.

 

 

Samples

 

Below you can find a couple of samples that demonstrate how to load waveform peaks in Visual Basic.NET and Visual C#

 

Visual Basic.NET

 

' memory buffers must be declared as global variables

Dim m_bufferMin() As Int16

Dim m_bufferMax() As Int16

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 ' get the size in bytes of the buffers

 Dim nBufferLength As Int32 = 0

AudioSoundRecorder1.DisplayWaveformAnalyzer.PeaksBufferLengthGet (nStartPosInMs, nEndPosInMs, nBufferLength)

 

 ' reallocate the memory buffer space and store the song

 ReDim m_bufferMin(nBufferLength/2)

 ReDim m_bufferMax(nBufferLength/2)

 

 ' fill the buffers with peaks data

AudioSoundRecorder1.DisplayWaveformAnalyzer.PeaksBufferGet (0, nStartPosInMs, nEndPosInMs, true, m_bufferMin, m_bufferMax, nBufferLength)

End Sub

 

 

Visual C#.NET

 

// declare the memory buffer (cannot be a local variable)

Int16[] m_bufferMin = null;

Int16[] m_bufferMax = null;

 

private void buttonLoad1_Click(object sender, System.EventArgs e)

{

 // get the size in bytes of the buffers

 Int32 nBufferLength = 0;

AudioSoundRecorder1.DisplayWaveformAnalyzer.PeaksBufferLengthGet (nStartPosInMs, nEndPosInMs, ref nBufferLength);

 

 // reallocate the memory buffer space and store the song

 m_bufferMin = new Int16[nBufferLength/2];

 m_bufferMax = new Int16[nBufferLength/2];

 

 // fill the buffers with peaks data

AudioSoundRecorder1.DisplayWaveformAnalyzer.PeaksBufferGet (0, nStartPosInMs, nEndPosInMs, true, m_bufferMin, m_bufferMax, nBufferLength);

}