Play One Audio File Simultaneously in Windows 8 (C#/XAML) - c#

I want to play many sound effect simultaneously from one audio file. So, I have an audio.wav file and I want to play it independently when I click a button. I have found similar question in here, but the solution not work for me because there is a lag between the sound. I have also try to use SharpDX from here but it still have a lag between the sound and sometimes it won't play.
In Windows Phone, I use SoundEffect and it works perfecly. Any solution for my problem?
Any ideas would be greatly appreciated. :)

Related

Taking pictures and recording multimedia files from WPF-application

we are in need of a way to record videos with sound and taking pictures inside a WPF-application. It should be able to save locally to disk. Preferably it should be able to show the content once it is saved as well, but if no such component exists, we will use another component for the playback.
I've looked around and found no real good options to do this. Some options lack the sound recording in videos, and some are just too old to get working properly (WPF has had a long run so far...)
Does anyone here has any experience in this specific area?
Got Taking Pictures and Videos working with this little documentation https://www.codeproject.com/Articles/330177/Yet-another-Web-Camera-control
If you dont tell us what problems exactly you got, or which code you already got, we can't really help.

Media Player seek option not working properly

Hello fellow developers.
I made a c# player to play videos and audio. To do that I used the System.Windows.Media MediaPlayer and it works great.
Here is the problem I encountered:
In some music files (not all of them) seeking to X time or playing it from the beginning to X time will have diffrent results.
In other words, If I play the song from the beginning, after 20 seconds the singer will say "Hello" but if I use the seek function to 20 sec I will hear the singer say something else (and 2 seconds later he will say "Hello").
I had to check if its the library mistake so I opened windows media player and played the song, When I click on the progress bar to X progress or when I play from the beginning to X progress the song is at different time.
Same like the library.
I checked this with VLC and it worked perfectly.
So here is my questions to you.
Does it mean that Media Player doesn't know how to seek this music file correctly?
Do you know how to fix this?
Should I use a different player, which one do you recommend?
I found the problem,
Encoding the audio as VBR made it happen like that.
Changing to CBR solved this.

Play two sounds parallel in background agent

I have a mp3 file. I have a background sound file like rain sound or some fire sound. I want to play these two files parallel in the app as well as in background. So that it looks like a single music is playing a story with a background. Please provide any guidance to achieve this.
AFAIK there are four ways to play audio in WP: BackgroundAudioPlayer, MediaElement, SoundEffect, Microsoft Media Foundation. As for your question:
BackgroundAudioPlayer - it won't work, as there is only one Instance of BAP on the phone. So to play a different file, you have to change Track's Source, so it won't handle two at the same time.
MediaElement - it's also a bad idea (it won't also run with BAP simultanously), because as MSDN says:
When a MediaElement control plays audio or video content, any background sounds or media already playing are halted. The app launches the playback experience when the user taps the control. Only one MediaElement control can operate at a time.
you can try to play many sounds using SoundEffect (thougt as Documentation says it can be only a wave file), I won't post code here, because there are already many examples: one, two, three
as for Microsoft Media Foundation: Walkthrough, Programming Guide, Supported file formats

Easiest way to play audio in an openTK application, using any method

My goal here is to be able to play an MP3 in an OpenTK/OpenGL application (.NET but NOT windows forms), being able to stop/play/pause it, access/set the position of the audio file, and have it play to within a few milliseconds of when I tell it to.
I've tried using WindowsMediaPlayer (WMPLib) but for whatever reason the audio doesn't start playing until I resize or move the window. Not sure why but it probably has something to do with the fact that it's meant to be a control on Windows Forms, and this is a GL application.
I've tried using .NET's soundplayer but that incurs a huge delay of up to a second, and I can't set/access the position of the file.
I've looked into OpenTK and OpenAL but that seems way too complex to figure out.
Does anyone have any ideas?
THANKS!
Oh and worst case scenario I could also deal with playing WAV or OGG files instead, and if the play timing is accurate enough I wouldn't need access to the position of the audio.
OpenAL may seem complicated, but it sounds like the best solution to your problem. There's plenty out there on it, though most examples might be in other languages, but the API is the same. Perhaps this thread has some solutions as well.

How can I play a .wav file using SharpDX DirectSound in a C# WPF project?

I want to be able to precisely control the timing of .wav files played in my program. I also want to be able to play more than one .wav file at the same time. The SoundPlayer was not good enough because I can't play two sounds at once, and even when I play different sounds consecutively, there is about a 1/8th second delay between each sound, which is unacceptable for what I am doing. I cannot find a way to add a Device using SharpDX.
You have a directsound sample in sharpdx, should get you started.
Also you can have a look at NAudio , which should also fit your needs and be a bit easier to use.

Categories