19 May '13 - 06:38 *
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: wav to mp3 in vb.net  (Read 1190 times)
reno
Posts: 24


« on: 1 May '08 - 18:30 »
Reply with quoteQuote

hi,

this code doesn't work, but what's wrong ?


the output file still at 0Kb


 Bass.BASS_Init(-1, 11025, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Nothing)

        H = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_STREAM_PRESCAN)

        LL = New EncoderLAME(H)
        LL.OutputFile = IO.Path.ChangeExtension(File, ".mp3")
        LL.LAME_Bitrate = EncoderLAME.BITRATE.kbps_128
        LL.LAME_Mode = EncoderLAME.LAMEMode.Mono
        LL.LAME_TargetSampleRate = EncoderLAME.SAMPLERATE.Hz_11025


        LL.LAME_Quality = EncoderLAME.LAMEQuality.Q5

        LL.EncoderDirectory = Application.StartupPath
        Dim b As Boolean = LL.EncoderExists


  LL.Start(Nothing, IntPtr.Zero, False)
        Bass.BASS_ChannelPlay(H, False)


thank

Logged
radio42
Posts: 4012


« Reply #1 on: 1 May '08 - 20:16 »
Reply with quoteQuote

A decoding channel can not directly being played via "BASS_ChannelPlay".
Instead you need to call "BASS_ChannelGetData" in a loop to decode all the data.

There is a little helper method available in the "Utils" class, so simply add the following to your code instead of calling "BASS_ChannelPlay":
Utils.DecodeAllData(H, True)
Logged
reno
Posts: 24


« Reply #2 on: 5 May '08 - 18:01 »
Reply with quoteQuote

ok thank you, it's work fine

but about progress state with this methode

thanks
Logged
radio42
Posts: 4012


« Reply #3 on: 5 May '08 - 21:01 »
Reply with quoteQuote

The method has no progress state.
If that's needed you would have to implement it yourself. Here is some sample code:
public static long DecodeAllData(int channel, bool autoFree)
        {
            // encode all the data right away
int len;
            long decBytes = 0;
            byte[] buffer = new byte[131072];
            while (Bass.BASS_ChannelIsActive(channel) == BASSActive.BASS_ACTIVE_PLAYING)
            {
                // get the decoded sample data
                len = Bass.BASS_ChannelGetData(channel, buffer, 131072);

if (len < 0)
break;
else
decBytes += len;
            }

            if (autoFree)
                Bass.BASS_StreamFree(channel);

            return decBytes;
        }
Logged
reno
Posts: 24


« Reply #4 on: 6 May '08 - 07:06 »
Reply with quoteQuote

thank i'll try it soon...


i have an another question about bass without answer....

http://www.un4seen.com/forum/?topic=8420.0

Thanks
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines