Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Changing output sound device in "realtime"

Racine
Registered User
Quote
2008-05-10 01:03:08

Hi everybody,

I have just found your Sound engine today, and I very appreciate it, he have really changing my life ( at less for today  :P ).
And I have a little question for this evening,
I seek a solution which would enable me to choose in "real time" the output sound device for the current playback.
I clarify my demand :
When I launch ISoundEngine to play a file ( *mp3 in 2D ,.... etc) through a specific output device ( first  available for example ), I would like to change the device without lose position in my current file.
After a strong brainstorming with me and myself, I found some beginning solution, but nothing really run.
The difficulty for this function comes to the fact what when we would change the device, no function is usable. And we are obliged to destroy and recreate an ISoundEngine object, but we lose the seek position in file.

Someone have a solution in its basket ? I take every all ideas. Thx

and sorry for the bad english but I'm French ...... I know ... I know ......  :P


erik
Guest
Quote
2008-05-10 05:07:57

What about getting the seek position of the playing file, destroying the engine, recreating it with the new sound driver, starting the old played file paused, setting the old seek position and unpausing the sound?


Racine
Registered User
Quote
2008-05-10 14:51:32

[quote=erik (Guest)]What about getting the seek position of the playing file,[/quote]
Maybe I'm mistaken, but he don't exist a propertie or method to get the current position.
[quote=erik (Guest)] destroying the engine, recreating it with the new sound driver, starting the old played file paused, setting the old seek position and unpausing the sound?[/quote]
And if you destroy the ISoundEngine, you destroy the old played file too, because the file is binding to ISoundSource to ISoundEngine.

Thank for the reply






erik
Guest
Quote
2008-05-10 16:38:20

Of course there is a method for getting the play position: [url=http://www.ambiera.com/irrklang/docu/classirrklang_1_1_i_sound.html#d8edf019757e44c683b14424abc2275c]getPlayPosition[/url]


Racine
Registered User
Quote
2008-05-10 22:38:00

Indeeds, I don't see this propertie in class ISound , thanks a lot Erik.
Here is my source code for the solution :


static void Main(string[] args)
            {

            ISoundDeviceList sndDev = new ISoundDeviceList(SoundDeviceListType.PlaybackDevice);
            
            ISoundEngine sndEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions, sndDev.getDeviceID(1));
            ISound snd = sndEngine.Play2D(@"C:\getout.ogg");
            
            _getch();
        
            uint pos = snd.PlayPosition; // here is the cursor in the current file who is playing at this moment
            sndEngine.StopAllSounds();
            sndEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions, sndDev.getDeviceID(2));
            snd = sndEngine.Play2D(@"C:\getout.ogg");
            snd.PlayPosition = pos; // reload the previous position.
            
            _getch();

         }


If you are any questions or improvements .... post it


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact