BASS.NET API for the Un4seen BASS Audio Library

WaveFormAddMarker Method (String, Int64)

BASS.NET API for the Un4seen BASS Audio Library
Add or replace a marker to the WaveForm.

Namespace:  Un4seen.Bass.Misc
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

public bool AddMarker(
	string name,
	long position
)

Parameters

name
Type: SystemString
The name of the marker to add or replace.

You might specify an optional marker color by adding the following string to the end of the name: "{Color=colorname}" or "{Color=0xhexcolor}" Example: "My Marker1{Color=Gray}", "My Marker2{Color=0x78FF0000}"

Note: On the CE version of BASS.NET you can only specify a hex color value.

You might specify an optional marker alignment by adding the following string to the end of the name: "{Align=Left|Right|Center|Auto} (the default is Auto)." Example: "My Marker1{Align=Center}", "My Marker2{Color=0x78FF0000}{Align=Right}"

position
Type: SystemInt64
The position (in bytes) of the marker (e.g. as returned by BASS_ChannelGetPosition(Int32, BASSMode)).

Return Value

Type: Boolean
, if the marker was added or replaced successfully, else .
Remarks

Markers might be used to highlight certain positions within a WaveForm, e.g. Cue-, Ramp-, Fade- or Mix-Points.

Use the DrawMarker property to define if and how markers should be drawn within the WaveForm. The ColorMarker property will be used as the the drawing color.

In order to remove a marker use the RemoveMarker(String) or ClearAllMarker methods.

Before adding markers the Wave buffer must have been created. So make sure this method is only called after WaveFormLoadFromFile(String), RenderStartRecording(Int32, Int32, Int32) or RenderStart(Int32, Boolean).

Use the GetMarker(String) method to retrive a certain marker position. To obtain a list of all markers you might use the GetMarkers or GetMarkerCount methods.

If your rendering method and your playback stream used different flags during creation (e.g. rendering was done using the BASS_DEFAULT flag whereas your playback stream uses BASS_SAMPLE_FLOAT) adding markers might result in a different position, meaning the position would reflect a different value during playback. In such case call the SyncPlayback(Int32) method to ensure, that the position will be converted accordingly.

Note: The byte position will be converted to the original rendering resolution according the SyncPlayback(Int32). So if your playback stream has a different resolution never add marker positions without first calling SyncPlayback(Int32).

Examples

private Un4seen.Bass.Misc.WaveForm WF = null;
...
// render a wave form
WF = new WaveForm(_fileName, new WAVEFORMPROC(MyWaveFormCallback), this);
WF.FrameResolution = 0.01f; // 10ms are nice
WF.CallbackFrequency = 500; // every 5 seconds rendered (500*10ms=5sec)
WF.DrawMarker = WaveForm.MARKERDRAWTYPE.Line | 
                WaveForm.MARKERDRAWTYPE.Name | 
                WaveForm.MARKERDRAWTYPE.NamePositionAlternate;
// it is important to use the same resolution flags as for the playing stream!
// our already playing stream is 32-bit float - so this one will also need to be...
WF.RenderStart( false, BASSFlag.BASS_SAMPLE_FLOAT );
// from here on we might add markers...just examples here...
WF.AddMarker( "CueIn", Bass.BASS_ChannelSeconds2Bytes(_stream, 2.0) );
WF.AddMarker( "RampUp", Bass.BASS_ChannelSeconds2Bytes(_stream, 17.5));
WF.AddMarker( "Outro", Bass.BASS_ChannelSeconds2Bytes(_stream, 100.7));
WF.AddMarker( "Mix", Bass.BASS_ChannelSeconds2Bytes(_stream, 130.3));
WF.AddMarker( "End", Bass.BASS_ChannelSeconds2Bytes(_stream, 136.9));
...
// this will replace the 'RampUp' marker
WF.AddMarker( "RampUp", Bass.BASS_ChannelSeconds2Bytes(_stream, 19.2));
See Also

Reference