BASS.NET API for the Un4seen BASS Audio LibraryVisualsGetFrequencyFromPosX Method BASS.NET API for the Un4seen BASS Audio Library
Returns the frequency in Hz represented by the given X coordinate position of a visual control.

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

public int GetFrequencyFromPosX(
	int x,
	int samplerate
)

Parameters

x
Type: SystemInt32
The X coordinate from which to get the frequency (between 0 and control.Width-1).
samplerate
Type: SystemInt32
The current samplerate of the channel which was used to render the visual (e.g. use BASS_ChannelGetInfo(Int32, BASS_CHANNELINFO) to retrieve the current samplerate of the respective channel).

Return Value

Type: Int32
The frequency in Hz which is represented by the X coordinate of the visual.
Remarks

The X coordinate position represents the zero based pixel number of the visual control being rendered.
Examples

In the following example a pictureBox control is assumed being used:
VB
Private Sub pictureBoxSpectrum_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs)
  If _vis Is Nothing Then
    Return
  End If
  Dim freq As Integer = _vis.GetFrequencyFromPosX(e.X, 44100)
  Dim amp As Single = _vis.GetAmplitudeFromPosY(e.Y, Me.pictureBoxSpectrum.Height)
  Me.labelVis.Text = [String].Format("Freq={0}Hz, Amp={1}", freq, amp)
End Sub
private void pictureBoxSpectrum_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (_vis == null)
     return;
  int freq = _vis.GetFrequencyFromPosX(e.X, 44100);
  float amp = _vis.GetAmplitudeFromPosY(e.Y, this.pictureBoxSpectrum.Height);
  this.labelVis.Text = String.Format( "Freq={0}Hz, Amp={1}", freq, amp );
}
See Also

Reference