Copyright © 2001-2018 MultiMedia Soft

Waveform.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 Waveform.PeaksBufferLengthGet method.

 

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

 

For further details about using the embedded Waveform refer to the Waveform object section.

For further details about generating a waveform bitmap of the loaded sound, before starting its playback, refer to the How to obtain the sound's waveform tutorial.

 

 

Syntax

 

[Visual Basic]

control.Waveform.PeaksBufferGet (

nPlayer as Integer,

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.Waveform.PeaksBufferGet (

short nPlayer,

short nChannel,

long nStartPos,

long nEndPos,

short bValueInPerc,

const VARIANT FAR& pBufferMin,

const VARIANT FAR& pBufferMax,

long nBufferLength

);


 

 

Parameter

Description

 

 

nPlayer

Number representing the zero-based index of the player that will use the waveform.

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

 Amp3dj1.Waveform.PeaksBufferLengthGet 0, nStartPosInMs, nEndPosInMs, nBufferLength

 

 ReDim m_bufferMin(nBufferLength/2)

 ReDim m_bufferMax(nBufferLength/2)

 

 ' fill the buffers with peaks data

 Amp3dj1.Waveform.PeaksBufferGet 0, 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;

 m_ctrlActiveDJ.GetWaveform().PeaksBufferLengthGet (0, nStartPosInMs, nEndPosInMs, nBufferLength);

 

 m_bufferMin = new short[nBufferLength/2];

 m_bufferMax = new short[nBufferLength/2];

 

 // fill the buffers with peaks data

 Amp3dj1.GetWaveform().PeaksBufferGet (0, 0, nStartPosInMs, nEndPosInMs, TRUE, m_bufferMin, m_bufferMax, nBufferLength);

}