Show Posts
|
|
Pages: [1]
|
|
2
|
Developments / BASS / Re: Latency on BASS_Mixer_StreamAddChannel
|
on: 11 Mar '13 - 16:10
|
|
Thank you Ian.
I changed my code to use BASS_Mixer_ChannelSetEnvelope. Can you confirm to me that I can use a floating point number with BASS_ChannelSeconds2Bytes ? Because I need to use milliseconds to fade in/out.
About my latency problem, your comment makes me think a problem with the IceCast encoding function. So I would like to use code below but there is "glitch" and some problem with buffer I think. As if I had a bad Internet connection with a poor speed. So, I thought to use BASS_ChannelGetData but I don't know if it's correct especially about buffer and lenght.
ENCODER Dim encoder = BassEnc.BASS_Encode_Start(StreamMixed(0), "lame -r -s 44100 -b 128 -", BASSEncode.BASS_ENCODE_NOHEAD, Nothing, 0) BassEnc.BASS_Encode_CastInit(encoder, "127.0.0.1:8000/stream", "password", BassEnc.BASS_ENCODE_TYPE_MP3, "name", "", "", Nothing, Nothing, 128, True)
CHANNELGETDATA Do While BassEnc.BASS_Encode_IsActive(encoder) <> BASSActive.BASS_ACTIVE_STOPPED Dim length As Integer = CInt(Bass.BASS_ChannelSeconds2Bytes(StreamMixed(DepartureNbr), 0.01)) Dim data(length) As Byte Bass.BASS_ChannelGetData(StreamMixed(0), data, length) Loop
|
Reply
Quote
|
|
|
3
|
Developments / BASS / [SOLVED] Latency on BASS_Mixer_StreamAddChannel
|
on: 4 Mar '13 - 17:35
|
|
Hello,
Here is what my software doing : 1) It decodes a stream IceCast 2) Split the IceCast's stream X times 3) Detects a frequency and mix a sound file 4) Encode the result to another mount point IceCast
The application does not play sound on a sound card, everything is done by decoding.
My problem is when it detects the frequency, the fadeout is good but the sound file is started with a random time ! This can be instantaneous or take several seconds. Is it a problem with Bass.Net and buffer or something like that. Or with multi-threading ?
Thank you very much for your help.
Here is a sample of my code :
' INITIALIZING ' Create stream mixer in a thread StreamMixed(i) = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE) ' Create stream for each file to play in another thread StreamFile(i, j) = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_STREAM_DECODE) ' Create stream for "IceCast in" in another thread Dim StreamDecodedSource = Bass.BASS_StreamCreateURL(Source, 0, BASSFlag.BASS_STREAM_DECODE, Nothing, IntPtr.Zero) ' Split "IceCast in" stream for each stream mixer in another thread StreamDecoded(i) = BassMix.BASS_Split_StreamCreate(StreamDecodedSource, BASSFlag.BASS_STREAM_DECODE, Nothing) ' Adding stream "IceCast in" to each stream mixer in the same thread of above BassMix.BASS_Mixer_StreamAddChannel(StreamMixed(i), StreamDecoded(i), BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_MIXER_DOWNMIX)
' CRUISING 'Streaming to IceCast out in a new thread Dim Lame As New EncoderLAME(StreamMixed(DepartureNbr)) Lame.InputFile = Nothing Lame.OutputFile = Nothing Lame.LAME_Bitrate = CInt(EncoderLAME.BITRATE.kbps_128) Lame.LAME_Mode = EncoderLAME.LAMEMode.Default Lame.LAME_TargetSampleRate = Int(EncoderLAME.SAMPLERATE.Hz_44100) Lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality Lame.Start(Nothing, IntPtr.Zero, False) Dim IceCast As New ICEcast(Lame) IceCast.ServerAddress = ServersToStream(i, 1) IceCast.ServerPort = ServersToStream(i, 2) IceCast.Username = ServersToStream(i, 3) IceCast.Password = ServersToStream(i, 4) IceCast.MountPoint = ServersToStream(i, 5) IceCast.StreamName = ServersToStream(i, 0) IceCast.StreamGenre = "" IceCast.PublicFlag = False IceCast.SongTitle = "" If IceCast.Connect() Then If IceCast.Login() Then If IceCast.IsConnected() Then Dim m_BroadCast As New BroadCast(IceCast) m_BroadCast.AutoReconnect = True m_BroadCast.ReconnectTimeout = 5 Dim length As Integer = CInt(Bass.BASS_ChannelSeconds2Bytes(StreamMixed(i), 0.03)) Dim data(length) As Byte Dim length2 As Integer Do While IceCast.IsConnected() length2 = Bass.BASS_ChannelGetData(StreamMixed(i), data, length) Loop End If End If End If ' Checking for frequency in stream "IceCast in" in another thread Dim P As Visuals = New Visuals() Dim Freq = P.DetectFrequency(StreamMixed(i), 16495, 16505, False) If Freq >= CDbl("1") Then Dim PlayWayBThread As New Thread(AddressOf PlayWayB) PlayWayBThread.IsBackground = True PlayWayBThread.Start(i) End If ' PlayWayB adding file to a stream mixer, and mute/unmute "IceCast in" in new thread Dim AudioFadeOutThread As New Thread(AddressOf AudioFadeOut) ' Fade out source AudioFadeOutThread.IsBackground = True AudioFadeOutThread.Start(DepartureNbr) AudioFadeOut(DepartureNbr) Dim StreamWayB = BassMix.BASS_Mixer_StreamAddChannel(StreamMixed(i), StreamFile(i, SelectedFile), BASSFlag.BASS_STREAM_AUTOFREE) ' Play sound file Thread.Sleep(CInt(Playlist(DepartureNbr, SelectedFile(DepartureNbr) - 1, 0))) ' Waiting to end of file
Dim AudioFadeInThread As New Thread(AddressOf AudioFadeIn) ' Fade in source AudioFadeInThread.IsBackground = True AudioFadeInThread.Start(i)
' Here is sub of fade out and in AudioFadeOut() Bass.BASS_ChannelSlideAttribute(StreamDecoded(i), BASSAttribute.BASS_ATTRIB_VOL, 0, ChannelAFadeOutTime)
AudiFadeIn() Bass.BASS_ChannelSlideAttribute(StreamDecoded(i), BASSAttribute.BASS_ATTRIB_VOL, 1, ChannelAFadeOutTime)
|
Reply
Quote
|
|
|
6
|
Developments / BASS / Multiple Bass_Mixer_Stream ?
|
on: 29 Jan '13 - 09:08
|
|
Hello,
I need to decode one ShoutCast/IceCast stream and duplicate to many encoders ShoutCast/IceCast. Each of else can have one or multiple sound files mixed like this schema :
Playing a stream ShoutCast | | Mixing with File #1 ----| | | |-------------------------------------------> Streaming to IceCast #1 | | Mixing with File #2 ----| | | |-------------------------------------------> Streaming to IceCast #2 | | Mixing with File #3 ----| | | |-------------------------------------------> Streaming to IceCast #3 | | Mixing with File #4 ----| | | |-------------------------------------------> Streaming to IceCast #4 | Etc.
Here is my code, that work for only one stream decode/mixing/encode :
StreamMixed = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE) StreamIceCast = Bass.BASS_StreamCreateURL(ChannelASource, 0, BASSFlag.BASS_STREAM_DECODE, Nothing, IntPtr.Zero) BassMix.BASS_Mixer_StreamAddChannel(StreamMixed, StreamIceCast, BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_MIXER_DOWNMIX) 'Here is the code to encode to IceCast/ShoutCast Bass.BASS_ChannelSlideAttribute(StreamIceCast, BASSAttribute.BASS_ATTRIB_VOL, 0, 1000) StreamFile = Bass.BASS_StreamCreateFile("c:\test.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE) BassMix.BASS_Mixer_StreamAddChannel(StreamMixed, StreamFile, BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_MIXER_DOWNMIX) Bass.BASS_ChannelSlideAttribute(StreamIceCast, BASSAttribute.BASS_ATTRIB_VOL, 1, 1000)
Thank you for your help
|
Reply
Quote
|
|
|
9
|
Developments / BASS / BASS API .NET + System.TypeInitializationException
|
on: 7 Mar '12 - 11:59
|
|
Hello,
I use last version of API .NET BASS and BASS.DLL and with the example wich is in the help I've always these errors : Exception 'System.TypeInitializationException' in my app.exe Exception 'System.InvalidOperationException' in mscorlib.dll (4 times) Exception 'System.TypeInitializationException' in my app.exe
I'v BASS.DLL, BASS.NET.XML and BASS.NET.DLL in \bin\Debug. It seems it's a problem with "Imports Un4seen.Bass".
But everything works fine, I listen to the sound, etc.
I don't understand... Can you give me some help, please ?
|
Reply
Quote
|
|
|