19 May '13 - 21:30 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Record and Misc.Visuals  (Read 560 times)
wiesi-94
Posts: 3


« on: 28 Jun '12 - 19:10 »
Reply with quoteQuote

Hi!

I hav a problem with bass.net.dll!
Every time when i use a record stream for the visualisation of Misc.Visuals the pictureBox is starting flicker!
But visuals and a normal Steam is working very well.

Here is my code:
Form Load:
        BassNet.Registration("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx")
        BASS_Init(-1, 44100, 0, Me.Handle)
     
        BASS_RecordInit(-1)
        BASS_RecordSetInput(0, Un4seen.Bass.BASSInput.BASS_INPUT_ON, 1)

        Record = BASS_RecordStart(44100, 1, 0, Nothing, Nothing)
        '//Record = BASS_StreamCreateFile("D:\Daten\Musik\WTF! - Da Bop.mp3", 0, 0, 0)
        BASS_ChannelPlay(Record, True)
        Timer1.Enabled = True



Timer(invervall = 10):
       PictureBox2.Image = vis.CreateSpectrumLinePeak(Record, PictureBox1.Width, PictureBox1.Height, Color.Red, Color.Green, Color.Blue, Color.Black, 15, 5, 2, 10, True, True, False)
        'PictureBox1.Image = vis.CreateWaveForm(Record, PictureBox1.Width, PictureBox1.Height, Color.Red, Color.Green, Color.Blue, Color.Black, 1, True, False, False)
        PictureBox1.Image = Draw(Record, PictureBox1.Width, PictureBox1.Height, Color.Red, Color.Black, 1)
        Dim peak(2) As Single
        Bass.BASS_ChannelGetLevel(Record, peak)
        ProgressBar1.Value = peak(2) * 100
        ProgressBar2.Value = peak(1) * 100

I hope you can help me to find the problem, despite my poor English.
Logged
radio42
Posts: 4012


« Reply #1 on: 28 Jun '12 - 23:20 »
Reply with quoteQuote

The visuals call BASS_ChannelGetData internally to gather the FFT representation.
So it sounds like the visuals are 'stealing' data from the recording buffer (making it almost empty)...so that the next time there is no sufficient data available.
Also note, that calling it every 10ms wouldn't make much sense, if your update period (default is 50ms as far as I remember) is higher.

So one way would be to 'buffer' your recorded data in e.g. a push stream and call the visual on that one.
Logged
wiesi-94
Posts: 3


« Reply #2 on: 29 Jun '12 - 17:52 »
Reply with quoteQuote

The visuals call BASS_ChannelGetData internally to gather the FFT representation.
So it sounds like the visuals are 'stealing' data from the recording buffer (making it almost empty)...so that the next time there is no sufficient data available.
But when i call BASS_ChannelGetData manually it works fine!:
    Private Function Draw(ByVal Stream As Integer, ByVal Weite As Integer, ByVal Höhe As Integer, ByVal Color As Color, ByVal BackRound As Color, ByVal dicke As Integer) As Image
        'Weiten Berechnung
        Dim weiten(1024) As Integer
        Try
            Dim w As Double
            w = Weite / (1023 / 5)
            ReDim weiten(Weite + 1)
            If w < 1.0F Then
                For i = 0 To Weite
                    weiten(i) = i
                Next
            Else
                For i = 0 To Weite
                    weiten(i) = i * w
                Next
            End If
            If Höhe = 0 Or Weite = 0 Then Throw New Exception("Null Exception")
        Catch ex As Exception
            Return Nothing
        End Try

        'Daten Auslesen
        Dim OSC(1023) As Integer
        Dim oLeft, oRight As Single
        Dim OSCData(1023) As Single

        Un4seen.Bass.Bass.BASS_ChannelGetData(Stream, OSC, 1024)
        'MsgBox(API.BASS_ErrorGetCode.ToString)
        For i = 0 To 511
            oLeft = Un4seen.Bass.Utils.HighWord(OSC(i))
            oRight = Un4seen.Bass.Utils.LowWord(OSC(i))
            Dim y As Single = ((oLeft + oRight) / (2 * 65535)) * (Höhe)
            OSCData(i) = y
        Next

        'Zeichnen

        Dim bmp As New Bitmap(Weite, Höhe)


        Dim Scalc As Integer = 1
        Dim pen As New System.Drawing.Pen(Color, dicke)

        Dim grfGraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp)
        Dim pen1 As New System.Drawing.Pen(BackRound, Höhe)
        grfGraphics.DrawLine(pen1, 0, CInt(Höhe / 2), Weite, CInt(Höhe / 2))

        Dim p1 As Point = New Point(0, Höhe / 2 - OSCData(0))
        Dim p2 As New Point

        For i = 0 To OSCData.Length - Scalc - 1 Step Scalc
            If Not i = 0 And weiten(i) = 0 Then Exit For
            p2 = New Point(weiten(i) + (Scalc * weiten(1)), Höhe / 2 - OSCData(i))  '

            grfGraphics.DrawLine(pen, p1, p2)

            p1 = p2

        Next

        pen.Dispose()
        pen1.Dispose()

        grfGraphics.Dispose()
        Return bmp
    End Function

So one way would be to 'buffer' your recorded data in e.g. a push stream and call the visual on that one.

How do I do that?
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #3 on: 29 Jun '12 - 18:07 »
Reply with quoteQuote

Please try adding a RECORDPROC function to your BASS_RecordStart call. The RECORDPROC function can simply contain a "return TRUE" statement.

If you don't provide a RECORDPROC function, the BASS_ChannelGetData calls will be removing data from the recording buffer, which may mean that there is insufficient data for the next call, eg. if the BASS_ChannelGetData calls are taking the data more quickly than the recording device is delivering it.
Logged
wiesi-94
Posts: 3


« Reply #4 on: 29 Jun '12 - 18:38 »
Reply with quoteQuote

It Works!!

you've really helped me very much! Thank You!
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines