Copyright © 2005-2019 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 class 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]

Public Function PeaksBufferGet (

nPlayerIndex as Int16,

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 nPlayerIndex,

Int16 nChannel,

Int32 nStartPos,

Int32 nEndPos,

bool bValueInPerc,

Int16[] pBufferMin,

Int16[] pBufferMax,

Int32 nBufferLength

);


 

[C++]

public: enumErrorCodes PeaksBufferGet (

Int16 nPlayerIndex,

Int16 nChannel,

Int32 nStartPos,

Int32 nEndPos,

bool bValueInPerc,

Int16 __gc[] pBufferMin,

Int16 __gc[] pBufferMax,

Int32 nBufferLength

);


 

 

Parameter

Description

 

 

nPlayerIndex

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 (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

AudioDjStudio1.DisplayWaveform.PeaksBufferLengthGet (0, 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

 AudioDjStudio1.DisplayWaveform.PeaksBufferGet (0, 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;

AudioDjStudio1.DisplayWaveform.PeaksBufferLengthGet (0, 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

AudioDjStudio1.DisplayWaveform.PeaksBufferGet (0, 0, nStartPosInMs, nEndPosInMs, true, m_bufferMin, m_bufferMax, nBufferLength);

}