24 May '13 - 05:34 *
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: Slow starting of mp3  (Read 1800 times)
patrikk
Posts: 8


« on: 27 Feb '11 - 19:42 »
Reply with quoteQuote

Hi,

I have a strange problem which occurs when I start a .mp3 file.
This problem only occurs in Windows 7 (not in Windows XP).

I start the .mp3 the following way:
     int stream = Bass.BASS_StreamCreateFile(location, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT);
     bool success = Bass.BASS_ChannelPlay(stream, false);

My system "hangs" for about five seconds on the line with BASS_ChannelPlay.
This never happened before when using Windows XP.

I'm using:
Bass .NET 2.4.4.0
Programming in C# (.NET 4.0)

Thanks for the help.

regards Patrik
Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #1 on: 28 Feb '11 - 14:38 »
Reply with quoteQuote

That is indeed strange. Does it only happen with MP3 files, not WAV/OGG/etc? If MP3 only, is that with a particular MP3 file or all, and when using the "mp3-free" or standard BASS.DLL version, or both?
Logged
patrikk
Posts: 8


« Reply #2 on: 4 Mar '11 - 14:58 »
Reply with quoteQuote

Hi,

thanks for the answer and sorry about the late replay. I had forgot to check the checkbox "Notufy me of replies".
I only use .mp3 in my system, so I dont know about the other formats.
It happens with any mp3 file.

This is no machine dependent issue because I have tried four different computers with Windows 7 (with XP there are no problems).
What is the "mp3-free" version?
I use the standard.

regards Patrik

Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #3 on: 4 Mar '11 - 15:08 »
Reply with quoteQuote

To confirm whether it does only affect MP3, please try another format. You can find some OGG files to test with here...

   http://www.vorbis.com/music/
Logged
patrikk
Posts: 8


« Reply #4 on: 28 Mar '11 - 18:51 »
Reply with quoteQuote

Hi,

I'm sorry of my really poor answering.
This is my "side-project", unfortunately work must be done before fun things.

I have now tested this both with ogg and mp3.
The same result

I also updated the BASS, I use the following code modules now:
Bass.NET.dll 2.4.7.3
bass.dll 2.4.7.1

As I mentiond this only happens when starting Windows the first time. After that everything works super fast.
Is there some "intialization" done? Putting the library to the GAC or something.

Just to be sure that there aren't any problem with my other system I created a new Visual Studio project with the following code (still the same result). If you want the whole solution I can send it to you.

       public Form1() {
            InitializeComponent();
            Un4seen.Bass.BassNet.Registration("X@gmail.com", "XXXX");  // replace X with correct information
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 5000);
        }

        private void button1_Click(object sender, EventArgs e) {

            DialogResult result = openFileDialog1.ShowDialog();
           
            if(result == System.Windows.Forms.DialogResult.OK){
                int stream = Bass.BASS_StreamCreateFile(openFileDialog1.FileName, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT);
                bool success = Bass.BASS_ChannelPlay(stream, false);
            }

        }



Logged
AName
Posts: 20


« Reply #5 on: 29 Mar '11 - 02:30 »
Reply with quoteQuote

You might want to try not calling ChannelPlay at all to see where the problem is occurring.

Also, I would add "Using System.Threading;" up top and call Thread.Sleep for 10 seconds before calling ChannelPlay.

Maybe these two will help diagnose your problem.
Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #6 on: 29 Mar '11 - 17:57 »
Reply with quoteQuote

As I mentiond this only happens when starting Windows the first time. After that everything works super fast.

Everything will generally be slower to load/start the first time, and then subsequently faster as the files can be read from memory (cached from the first time). A 5 second difference sounds a bit extreme though. To see whether it might be something specific to your app, please try to reproduce the problem with one of the pre-compiled examples in the C\BIN directory. If it happens with the examples too, I will send you a debug version to narrow-down where the delay is coming from.
Logged
patrikk
Posts: 8


« Reply #7 on: 29 Mar '11 - 20:49 »
Reply with quoteQuote

Hi,

Now I try with my laptop (two years old with Windows 7).
The delays are even worse.

AName
I used a timer to check the following:

TIMER START
int stream = Bass.BASS_StreamCreateFile(openFileDialog1.FileName, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT);
bool success = Bass.BASS_ChannelPlay(stream, false);
TIMER STOP

Here are some results:

Freshly restarted
20:12:22
20:12.47 (25 seconds between)

Second try (no restart, different mp3)
20:15:07
20:15:07 (0 seconds between)

Uncommenting the ChannelPlay row and a fresh restart
20:21:04
20:21:05 (1 second between)

Sleep 10 seconds
20:30:10
20:30:32 (22 seconds between)


Ian:
I tried the bass24\c\bin\basstest.exe
It worked fine, no delay. So the bass.dll doesn't seem to be the problem.
Could it be the way the Bass.NET is used?
Just to mention I compile with the X86 mode.


Thanks for the help!
Logged
radio42
Posts: 4012


« Reply #8 on: 29 Mar '11 - 23:35 »
Reply with quoteQuote

I just tried it here and I couldn't discover anything like that.

The only thing I might think of might be the loading time for assemblies (dlls) -as they are loaded whenever needed (i.e. the first time a method calls into an assembly which has not been loaded yet).
Logged
patrikk
Posts: 8


« Reply #9 on: 30 Mar '11 - 21:20 »
Reply with quoteQuote

Thanks,
I will dig into this more and try with some other computers (with Windows 7).
I have had the problem with two different computers, but maybe it is something in the setup.

Two questions;
- Which dll do you think is the problem, the bass.dll or the Bass.Net.dll, or the interaction between them?
- Could the operating system affect, if it is 32 or 64 bit?

Thanks!

Logged
patrikk
Posts: 8


« Reply #10 on: 4 Apr '11 - 18:36 »
Reply with quoteQuote

I have used Process Monitor to trace the delays. I got the following result.
As you can see there is a 38 second delay (bold line).

Do you have any ideas why this is happening?


19:31:11,4886069   TestSound.exe   5048   RegQueryValue   HKCU\Software\Microsoft\Multimedia\Audio\UserDuckingPreference   NAME NOT FOUND   Length: 144
19:31:11,4886281   TestSound.exe   5048   RegCloseKey   HKCU\Software\Microsoft\Multimedia\Audio   SUCCESS   
19:31:49,0892107   TestSound.exe   5048   Thread Exit      SUCCESS   Thread ID: 5108, User Time: 0.0000000, Kernel Time: 0.0000000
19:31:54,1185784   TestSound.exe   5048   RegQueryKey   HKCU\Software\Classes   SUCCESS   Query: Name
Logged
patrikk
Posts: 8


« Reply #11 on: 9 Apr '11 - 20:09 »
Reply with quoteQuote

Has anyone any clues?
It feels that I have tried everything.....

Is there some method I could call to initialize the process in the start of my application.
So the assembly is already initialized when trying to play the .mp3?
Something that just loads the assemby, that "doesn't actually do anything"?

Ian:
Is it possible to get this?
"I will send you a debug version to narrow-down where the delay is coming from....."
Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #12 on: 11 Apr '11 - 13:34 »
Reply with quoteQuote

Yes, I'll send you a debug version to try to confirm when/where exactly the delay is occurring.
Logged
patrikk
Posts: 8


« Reply #13 on: 16 May '11 - 19:09 »
Reply with quoteQuote

Hi,

just to close this post.

I got a lot of help from Ian trying to figure out the problem.
THANKS!!!

After a lot of analyzing and tracing the problem was found to be related to the following:
...."The log shows that the delay is occurring when DirectSound is told to start playing the stream,".....

I had the same problem when playing songs with Windows Media Player.


Unfortunately I wasn't able to solve this problem (to get things to work with Windows 7).
I tried a lot of different things:
- Uninstall all 3:rd party software (clean Windows install)
- Old and new sound card drivers
- External USB sound card
- Etc etc.


I guess it is a combination of different things (hardware and software) that causes the problem, but I couldn't find it.

So finally I gave up and installed Windows XP on that computer (and everything works nicely)!

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

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines