Copyright © 2008-2018 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 object section.

 

 

Syntax

 

[Visual Basic]

control.WaveformAnalyzer.PeaksBufferGet (

nChannel as Integer,

nStartPos as Long,

nEndPos as Long,

bValueInPerc as enumBoolean,

pBufferMin as Variant,

pBufferMax as Variant,

nBufferLength as Long

) as enumErrorCodes


 

[C++]

short control.WaveformAnalyzer.PeaksBufferGet (

short nChannel,

long nStartPos,

long nEndPos,

short bValueInPerc,

const VARIANT FAR& pBufferMin,

const VARIANT FAR& pBufferMax,

long 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, check the LastError property value in order to get the error code

enumErrorCodes.ERR_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 6 and Visual C++ 6.

 

Visual Basic 6

 

' memory buffers must be declared as global variables

Dim m_bufferMin() As Integer

Dim m_bufferMax() As Integer

 

Private Sub Command1_Click()

 Erase m_bufferMin

 Erase m_bufferMax

 

 ' get the size in bytes of the buffers

 Dim nBufferLength As Long

 ActiveSoundEditor1.WaveformAnalyzer.PeaksBufferLengthGet nStartPosInMs, nEndPosInMs, nBufferLength

 

 ReDim m_bufferMin(nBufferLength/2)

 ReDim m_bufferMax(nBufferLength/2)

 

 ' fill the buffers with peaks data

 ActiveSoundEditor1.WaveformAnalyzer.PeaksBufferGet 0, nStartPosInMs, nEndPosInMs, BOOL_TRUE, VarPtr(m_bufferMin(0)), VarPtr(m_bufferMax(0)), nBufferLength

End Sub

 

 

Visual C++ 6 with MFC

 

// memory buffers must be declared as global variables

short *m_bufferMin = NULL;

short *m_bufferMax = NULL;

 

void CMyDialog::OnButton1()

{

 if (m_bufferMin != NULL)

   delete m_bufferMin;

 if (m_bufferMax != NULL)

   delete m_bufferMax;

 

 // get the size in bytes of the buffers

 long nBufferLength;

 ActiveSoundEditor1.GetWaveformAnalyzer().PeaksBufferLengthGet (nStartPosInMs, nEndPosInMs, nBufferLength);

 

 m_bufferMin = new short[nBufferLength/2];

 m_bufferMax = new short[nBufferLength/2];

 

 // fill the buffers with peaks data

 ActiveSoundEditor1.GetWaveformAnalyzer().PeaksBufferGet (0, nStartPosInMs, nEndPosInMs, TRUE, m_bufferMin, m_bufferMax, nBufferLength);

}