Appending to a WaveStream - c#

I am trying to stream sound using Naudio. The thing I am having trouble with is that I can't write to a WaveStream. I tried making a queue of smaller WaveStream but I don't think this is not the way to go. How can I stream an mp3 file, or wave file over the network and start playing it even if it is not completely transferred?

Have a look at the BufferedWaveProvider, it can be used as an input to WaveOut and allows you to queue up buffers for playback. You would however need to decode the MP3 file frame by frame yourself using the MP3Frame class, as the MP3FileReader expects to be able to reposition to the end.

Related

C# Video Streaming

I'm developing a C# video streaming application using NReco library. At this moment I was able to encode audio and video separately and save data in to queue. I can stream video using UDP protocol without audio and it played nicely in ffplay equally I can stream audio using UDP protocol without video and it also played nicely.Now I want to merge these two streams in to one and stream through UDP protocol and player should play both audio and video. But I have no idea how to do it. I would appreciate if some one can give me any points to do this or any other different method achieve this.
Thank You.
The answer highly depends on the source of video and audio streams. NReco.VideoConverter is a wrapper to FFMpeg tool and it actually can combine video and audio streams (see filters configuration in FFMpeg documentation) if either video or audio input can be specified as ffmpeg input source (UDP stream or direct show input device).
If both video and audio data represented by byte stream in your C# code you cannot pass them together using NReco.VideoConverter (ConvertLiveMedia method) because it uses stdin for communicating with ffmpeg and only one stream can be passed from C# code.

How can I use mp3 files in Windows Phone 8?

in my windows phone gaming apps, I have to use lots of sound. Now I have seen that Windows phone does not support mp3 files. So I need to use the wav files. Any mp3 file which is just 500 kb size in mp3 format, when convert that to ".wav" it becomes min 2.5MB. It's actually eating up my apps size and unnecessarily the size of my apps is getting bigger.
Anyone know how can I use the mp3 file? In my solution I have a Asset folder and inside this folder all the ".wav" files are located.
How I am doing this let me write a code
SoundEffect effect;
Iinside constructor-
{
...
var soundFile = "Assets/Jump.wav";
Stream stream = TitleContainer.OpenStream(soundFile);
effect = SoundEffect.FromStream(stream);
And in the code
effect.Play();
Is there any better approach. In some thread I come to know that doing this is not a better way coding as it creates object and used up the system space. Please suggest what to do, how do I add mp3 files and write better code for working with sound files.
you can use BackgroundAudioPlayer to play your wav and mp3 files. SoundEffect class cannot play mp3 data
Go through this it's an entire app on it's own.
Background Audio WP
To use an MP3 file you would have to decode the MP3 into PCM in memory, and use that resulting stream in the SoundEffect.FromStream method.
Another thing you could try is encoding the wav files as ADPCM. This usually compresses the wave file at ratio of 4:1. If you can't use the stream directly, decoding of ADPCM is much more straightforward than decoding an mp3 file.
And one more thing you could try to save space is converting the uncompressed wave files into mono, and a lower sampling rate. You can perform listening tests on the sounds after the conversion to make sure that the loss in quality is acceptable or not.

Is it possible to buffer only a specified segment of a video file using MediaElement in Silverlight?

I have a scenario where I have to play certain segment from multiple video files. When I am trying to achieve it the complete video gets buffered into my temp folder. Because the files that I am using are very large files(> 500MB), it is taking time to buffer and during buffering playback is not smooth. Since I only have to play a small segment from the video, is it possible to buffer only the specified segment and not the complete file?

Play MP3 from stream

Is there any way to play MP3 directly from a memory stream (without any temp. files) using VB.NET or C#? or play from SQLCe database?
Thanks
I'll suggest you try Mp3Sharp. It is a port of JavaLayer and it is written in C#. I am currently using it and SlimDX to play ShoutCast Mp3 streams. So far it works very well. There is an Mp3Stream class which you use to read the stream and return a predetermined number of PCM bytes. You can write those bytes to a DirectSound buffer for playback if you wish.
IrrKlang can also do this for you.

NAudio - Streaming byte[] of wav makes it play slow

I am trying to read bytes from a wav file and send it across to a stream but it plays slowly.
Could you please help me to know the right way of populating the byte[]?
Thanks for you help.
are you using NAudio to both read the WAV file and play the data?
you need to make sure you use the same WaveFormat at both ends

Categories

Resources