19 May '13 - 02:10 *
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: BASS_StreamCreateFile return 0  (Read 661 times)
kio2008
Posts: 44


« on: 24 Feb '12 - 11:44 »
Reply with quoteQuote

I get 0 when i call StreamCreateFile
This is example code that i get on guide bass.
I get always 0 with various mp3 file and wav
I get BASS_ErrorGetCode BASS_ERROR_NOTAVAIL, what mean ?
I put this file in c:\Test, in Debug folder, in Release folder, but don'go

Try
            If Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) Then
                ' create a stream channel from a file
                Dim stream As Integer = Bass.BASS_StreamCreateFile("c:\test\test.mp3", 0, 0, BASSFlag.BASS_DEFAULT)
                If stream <> 0 Then
                    ' play the stream channel
                    Bass.BASS_ChannelPlay(stream, False)
                Else
                    ' error creating the stream
                    Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode())
                End If

                ' wait for a key
                Console.WriteLine("Press any key to exit")
                Console.ReadKey(False)

                ' free the stream
                Bass.BASS_StreamFree(stream)
                ' free BASS
                Bass.BASS_Free()
            End If
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
« Last Edit: 24 Feb '12 - 11:56 by kio2008 » Logged
radio42
Posts: 4012


« Reply #1 on: 24 Feb '12 - 12:04 »
Reply with quoteQuote

Try "C:\\test\\test.mp3"
The '\' char and needs to be escaped.
Logged
kio2008
Posts: 44


« Reply #2 on: 24 Feb '12 - 12:06 »
Reply with quoteQuote

Sad don't go, mmmmmmmm
Logged
BulleTTime
Posts: 28


« Reply #3 on: 24 Feb '12 - 12:38 »
Reply with quoteQuote

try c:/test/test.mp3, that worked for me.
Logged
kio2008
Posts: 44


« Reply #4 on: 24 Feb '12 - 13:12 »
Reply with quoteQuote

again don't go, it is strange.
I try on other folder, but the problem there is always

Wowwwwwww, now is okkkkkkkkkkkkkkkkkkkkk
The problem was here
Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)

With first parameter there 0 , with -1 there isn't problem
Logged
Ionut Cristea
Posts: 1372


« Reply #5 on: 24 Feb '12 - 14:04 »
Reply with quoteQuote

Initializing BASS with the device = 0 means that you don't want sound to be hear, while -1 is the default audio device.
Logged
radio42
Posts: 4012


« Reply #6 on: 24 Feb '12 - 15:04 »
Reply with quoteQuote

...or that you MUST use the BASS_DECODE flag with its stream creation.
Logged
kio2008
Posts: 44


« Reply #7 on: 25 Feb '12 - 11:28 »
Reply with quoteQuote

I use BASS_StreamCreateURL in this mode

sourceUrl = "http://159.253.145.180:7002"
stream1 = Bass.BASS_StreamCreateURL(sourceUrl, 0, BASSFlag.BASS_MUSIC_DECODE, Nothing, Me.Handle)

Then i use BASS_ChannelGetData for to load data

is this code correct ? because when i save data to the file mp3 is not correct .

Dim _data1 As Byte = New Byte(1000) {}
Dim _fs1 As FileStream

Dim retBytes As Integer
_fs1.OpenWrite("out.mp3")

Do While Bass.BASS_ChannelIsActive(stream1) = BASSActive.BASS_ACTIVE_PLAYING
            retBytes = Bass.BASS_ChannelGetData(stream1, _data1, 1000)
            _fs1.Write(_data1, 0, retBytes)
Loop

When I debug this code, the first time i see inside _data1 all 0 bytes, then after about 3 o 4 loop I see values bytes not 0 .
But when I stop loop and close file, I listen file on Windows Media Player and it get error
I hear the file out.mp3 only to verify if it is correct, but I don't need hear it . I must only save it.
« Last Edit: 25 Feb '12 - 11:33 by kio2008 » Logged
gnag
Posts: 160


« Reply #8 on: 25 Feb '12 - 22:00 »
Reply with quoteQuote

BASS_ChannelGetData returns sample Data I think, not your MP3 encoded Stream Data.
Logged
kio2008
Posts: 44


« Reply #9 on: 26 Feb '12 - 07:45 »
Reply with quoteQuote

This radio station transmit in mp3 format, how can I convert this data in mp3 format ?
Is there a method of bass library that do this ?

Thank you very much
Logged
gnag
Posts: 160


« Reply #10 on: 26 Feb '12 - 13:41 »
Reply with quoteQuote

Take a look in the Documentation, here they show how to Stream an MP3 File and Download the Data using a Streamproc Callback, you can try if this helps you.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines