Визуализация звукового спектра (bass.dll) - Visual Basic .NET
Формулировка задачи:
Получаю данные с канала
как теперь это дело визуализировать? Может кто делал что-то похожее?
Листинг программы
- Dim buffer(256) As Short
- Bass.BASS_ChannelGetData(stream, buffer, BASSData.BASS_DATA_FFT256)
Нашел такую штуку:
Листинг программы
- Public Sub Visual()
- Dim bit As Bitmap = New Bitmap(PicVis.Width, PicVis.Height)
- Dim graph As Graphics = Graphics.FromImage(bit)
- Dim RedPen As New Pen(Color.Red, 5)
- Dim YellowPen As New Pen(Color.Yellow, 5)
- Dim d(1023) As Single
- Dim playing As Integer
- Dim X As Integer
- Dim Y As Integer
- graph.SmoothingMode = SmoothingMode.AntiAlias
- playing = Bass.BASS_ChannelIsActive(stream)
- If playing = 0 Then Exit Sub
- Bass.BASS_ChannelGetData(stream, d, Un4seen.Bass.BASSData.BASS_DATA_FFT1024)
- For X = 0 To PicVis.Width Step 8
- Y = Math.Sqrt(d(X + 1)) * 3 * PicVis.Height ' - 4
- If Y > PicVis.Height Then Y = PicVis.Height
- graph.DrawLine(RedPen, X + 2, PicVis.Height, X + 2, PicVis.Height - Y)
- 'graph.DrawArc(RedPen, X + 2, PicVis.Height, PicVis.Width, PicVis.Height - Y, Y, Y)
- graph.DrawLine(YellowPen, X + 2, PicVis.Height - Y, X + 2, PicVis.Height - Y - 2)
- Next
- 'draw the visual onto the picturebox
- PicVis.Image = bit
- Try
- graph.Dispose()
- 'bit.Dispose()
- RedPen.Dispose()
- YellowPen.Dispose()
- bit = Nothing
- graph = Nothing
- RedPen = Nothing
- YellowPen = Nothing
- Catch ex As Exception
- End Try
- End Sub
Решение задачи: «Визуализация звукового спектра (bass.dll)»
textual
Листинг программы
- Public Sub wolume(ByVal Percentage As Integer)
- 'BASS_SetVolume(Percentage / 100)
- BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, Percentage / 100)
- End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д