21 May '13 - 18:05 *
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: BASSMix C# Console App Freq. Problem  (Read 626 times)
cristianf
Guest
« on: 6 Mar '12 - 20:50 »
Reply with quoteQuote

Hi All,
I'm having a strange problems with bassmix, in c# console application when i play a stream (mp3 file) all is fine, but when i play a stream through bassmix this stream sounds really accelerated.
All freq are seted to 44100.
the strange is that when i click and i scroll the text in the console app, the stream sounds normal, when i unclick, the stream is accelerated again.
Here is the code that i'm using:

Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            this.mixStream1 = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_SOFTWARE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP);
            Bass.BASS_ChannelPlay(this.mixStream1, false);
...
stream = Bass.BASS_StreamCreateFile(archivo, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            BassMix.BASS_Mixer_StreamAddChannel(this.mixStream1, stream, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_MIXER_FILTER | BASSFlag.BASS_MIXER_NORAMPIN | BASSFlag.BASS_MIXER_BUFFER);
           

Sorry my english.
Regards
Cristian
Logged
gnag
Posts: 160


« Reply #1 on: 6 Mar '12 - 21:53 »
Reply with quoteQuote

I just tried to reproduce your error but it works fine here, I even tried to scroll and click around in the Console Windows, it didnt affect the Playback Speed in any way.
Here is the Code of my Console Application which works without the Problem you described:

    class Program
    {
        private static int mixStream1 = 0;
        static void Main(string[] args)
        {
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            mixStream1 = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_SOFTWARE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP);
            Bass.BASS_ChannelPlay(mixStream1, false);
          int  stream = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            BassMix.BASS_Mixer_StreamAddChannel(mixStream1, stream, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_MIXER_FILTER | BASSFlag.BASS_MIXER_NORAMPIN | BASSFlag.BASS_MIXER_BUFFER);

            Console.WriteLine("Playback started");
            Console.ReadKey();
        }
    }
Logged
cristianf
Posts: 5


« Reply #2 on: 6 Mar '12 - 22:04 »
Reply with quoteQuote

I just tried to reproduce your error but it works fine here, I even tried to scroll and click around in the Console Windows, it didnt affect the Playback Speed in any way.
Here is the Code of my Console Application which works without the Problem you described:

I tested 2 internal sound cards and USB, windows 7 and windows xp, I'm using the latest version of bass / bassmix. c # express 2008, fw 3 and 4. all with the same problem.
Logged
cristianf
Posts: 5


« Reply #3 on: 6 Mar '12 - 22:24 »
Reply with quoteQuote

I just tried to reproduce your error but it works fine here, I even tried to scroll and click around in the Console Windows, it didnt affect the Playback Speed in any way.
Here is the Code of my Console Application which works without the Problem you described:

I tested 2 internal sound cards and USB, windows 7 and windows xp, I'm using the latest version of bass / bassmix. c # express 2008, fw 3 and 4. all with the same problem.

At last I found the problem, but I still need a solution, after creating the stream, I generate a thread to capture the information in this stream, if not start the thread, everything works fine, if the thread start the stream is accelerated , just reading this thread, position and peaks and performs some operations at the end of the stream
Thread th = new Thread(new ParameterizedThreadStart(this.crlStream));
                th.IsBackground = true;
                th.Start(stream);
Logged
gnag
Posts: 160


« Reply #4 on: 6 Mar '12 - 22:27 »
Reply with quoteQuote

It might be the case that your are using for example ChannelGetData to retrieve Data from your Stream in another Thread which just steals/consumes Data which therefore the Playback Stream cannot play.

Could you post a stripped-down Version of your C# Project Folder which just demonstrates the Problem for us to try to play around with it?
Logged
cristianf
Posts: 5


« Reply #5 on: 6 Mar '12 - 22:39 »
Reply with quoteQuote

It might be the case that your are using for example ChannelGetData to retrieve Data from your Stream in another Thread which just steals/consumes Data which therefore the Playback Stream cannot play.

Could you post a stripped-down Version of your C# Project Folder which just demonstrates the Problem for us to try to play around with it?

Yes, I'm using ChannelGetData.
If i use thread.sleep(500) i dont have problems, but when i reduce this to 400/300/200/100ms, the stream speed increases more and more.

To clarify, this only happens using bassmix.

Attached the proyect
« Last Edit: 7 Mar '12 - 17:23 by cristianf » Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #6 on: 7 Mar '12 - 15:09 »
Reply with quoteQuote

As gnag mentions, BASS_ChannelGetData will take data from the source ("stream") which is then not available for the mixer to play, and playback will sound fast because data is being skipped. To avoid that problem, you can use BASS_Mixer_ChannelGetData instead.
Logged
cristianf
Posts: 5


« Reply #7 on: 7 Mar '12 - 15:38 »
Reply with quoteQuote

Ian, gnag, thanks for your response,
If you can see the proyect attached, it reproduce the problem i have, in that example. BASS_ChannelGetData and BASSMix_Mixer_ChannelGetData aren't present

I'm using:

BASS_ChannelGetLength
BASS_ChannelBytes2Seconds
BASS_ChannelGetPosition
BASS_ChannelGetLevel
Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #8 on: 7 Mar '12 - 16:13 »
Reply with quoteQuote

Oh, right. You would also need to replace BASS_ChannelGetLevel with BASS_Mixer_ChannelGetLevel (BASS_ChannelGetLevel will take data from the source to get the level of it).
Logged
cristianf
Posts: 5


« Reply #9 on: 7 Mar '12 - 17:03 »
Reply with quoteQuote

Thanks, that works perfect!
« Last Edit: 7 Mar '12 - 17:20 by cristianf » Logged
gnag
Posts: 160


« Reply #10 on: 7 Mar '12 - 20:35 »
Reply with quoteQuote

I dont see your attachment but I think you solved the Problem already by using the Mixer calls which do not "steal" Data from the source Channel.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines