 |
|
|
 |
|
 |
Hi!
I have looked your code.
It is really good.
But in windows mobile i can't add some things.
I try my code in Windows Application, it's working.
But in mobile phone, it didn't find:
System.ComponentModel.Component..
It can be written in Windows Application, but i can't find in mobile app.
So i decide write a class is name "Component".
I copy the codes of System.ComponentModel.Component from windows Application.
But problems go on. How can I use your code in windows mobile.
Can you write me?
My email: m34alper@gmail.com
|
|
|
|
 |
|
 |
Hello everyone; we are currently using this code to do some real-time VST processing of MIDI input while a Flash interface displays on screen in the .NET application. Unfortunately sometimes (only occasionally on some machines, and over 50% of the time on others) audio being played by the Flash halts completely until WaveOut class begins writing to the sound buffer. Does anyone know of a reason why (relating to this code) that this problem might occur?
|
|
|
|
 |
|
 |
is it possible playing sound directly from microphone??
|
|
|
|
 |
|
 |
Im doing a similar project and till now, there is no problem until my sample rate goes somwhere above 400KHz is there any soloution to that? or do i have to down sample?
|
|
|
|
 |
|
 |
{"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
on
WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION));
Any idea why?
I tryed:
WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, null, 0, WaveNative.CALLBACK_FUNCTION));
and it works, almoust work it dont sound like music.
|
|
|
|
 |
|
 |
Project->Properties->Build->Platform Target: x86
|
|
|
|
 |
|
 |
I find this article intresting, but I can not download the code.
Is the code missing?
|
|
|
|
 |
|
 |
I want to set the max value of a progress bar to the length in seconds of the sound I loaded in System.Media.soundPlayer. how do I do that?
|
|
|
|
 |
|
 |
Hi. does anyone have a c++ code for a simple wma audio player? any help is greatly appreciated.
|
|
|
|
 |
|
 |
Hey everybody,
By using this code the application I have developed able to play and record audio/music. But it does not have a listener like what is available in socket programming. I need your help on how I will proceed to develop the listener.
Thanks in advance!
|
|
|
|
 |
|
 |
Problem: to deactivate the loop forces the WaveLib.WaveOutPlayer to stop immediately. that means that the very last part of the stream will not be played.
This is definitively the wrong way.
int got = m_AudioStream.Read(b, pos, toget);
//if (got < toget)
//{
//m_AudioStream.Position = 0; // loop if the file ends
//}
pos += got;
A Solution would be really good for me as I want to create a very small application for an Windows Mobile Pro.
Thank you.
|
|
|
|
 |
|
 |
Hi moserwi,
I wanted to do the same. And found a solution. The purpose is to add a "Loop" checkbox on the MainForm to enable/disable looping feature live.
I have added a member variable m_Loop and its get/set property to WaveOutPlayer.
Added the loop argument to constructor.
public class WaveOutPlayer : IDisposable
{
private bool m_Loop;
public bool Loop
{
get { return m_Loop; }
set { m_Loop = value; }
}
public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
: this(device, format, bufferSize, bufferCount, true, fillProc)
{
}
public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, bool loop, BufferFillEventHandler fillProc)
{
m_Loop = loop;
m_zero = format.BitsPerSample == 8 ? (byte)128 : (byte)0;
m_FillProc = fillProc;
WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION));
AllocateBuffers(bufferSize, bufferCount);
m_Thread = new Thread(new ThreadStart(ThreadProc));
m_Thread.Start();
}
}
Then the delegated needed to be changed in order to be notified when the stream had finished playing.
internal class WaveOutHelper
{
public delegate void BufferFillEventHandler(IntPtr data, int size, ref bool finished);
}
The Filler proc in MainForm had to match the delegate signature and needed to set "finished" variable to true when playing was done.
private void Filler(IntPtr data, int size, ref bool finished)
{
byte[] b = new byte[size];
if (m_AudioStream != null)
{
int pos = 0;
while (pos < size)
{
int toget = size - pos;
int got = m_AudioStream.Read(b, pos, toget);
if (got < toget)
{
finished = true; m_AudioStream.Position = 0; }
pos += got;
}
}
else
{
for (int i = 0; i < b.Length; i++)
b[i] = 0;
}
System.Runtime.InteropServices.Marshal.Copy(b, 0, data, size);
}
The playing thread had just to set its m_Finished variable to true only when m_Loop was false.
private void ThreadProc()
{
while (!m_Finished)
{
Advance();
if (m_FillProc != null && !m_Finished)
{
m_FillProc(m_CurrentBuffer.Data, m_CurrentBuffer.Size, ref m_Finished);
if (m_Finished && m_Loop)
m_Finished = false;
}
else
{
byte v = m_zero;
byte[] b = new byte[m_CurrentBuffer.Size];
for (int i = 0; i < b.Length; i++)
b[i] = v;
Marshal.Copy(b, 0, m_CurrentBuffer.Data, b.Length);
}
m_CurrentBuffer.Play();
}
WaitForAllBuffers();
}
I modified the Play procedure in order to pass the checkbox value to the WaveOutPlayer constructor. And everything works ok.
private void Play()
{
Stop();
if (m_AudioStream != null)
{
m_AudioStream.Position = 0;
m_Player = new WaveLib.WaveOutPlayer(-1, m_Format, BUFFER_SIZE, 3, chkLoop.Checked, new WaveLib.BufferFillEventHandler(Filler));
}
}
|
|
|
|
 |
|
 |
I used your patched version to play a file un-looped and I noticed a little bug.
If you play a file shorter than the buffer size, it plays twice (then stops).
You're missing a break in Filler function:
private void Filler(IntPtr data, int size, ref bool finished)
{
byte[] b = new byte[size];
if (m_AudioStream != null)
{
int pos = 0;
while (pos < size)
{
int toget = size - pos;
int got = m_AudioStream.Read(b, pos, toget);
if (got < toget)
{
finished = true; m_AudioStream.Position = 0; break;
}
pos += got;
}
}
else
{
for (int i = 0; i < b.Length; i++)
b[i] = 0;
}
System.Runtime.InteropServices.Marshal.Copy(b, 0, data, size);
}
Thanks for your patch
|
|
|
|
 |
|
 |
how can I stop when the incoming signal ends?
10Q
|
|
|
|
 |
|
 |
I'm actually having a lot of issues with playing any wav file in a WPF application, so i've been looking around for a demo that plays sound in any form that I can modify for my needs.
When I run your program and open a file and then press play I get the following error;
{"Object reference not set to an instance of an object."}
at WaveLib.WaveNative.waveOutOpen(IntPtr& hWaveOut, Int32 uDeviceID, WaveFormat lpFormat, WaveDelegate dwCallback, Int32 dwInstance, Int32 dwFlags)
at WaveLib.WaveOutPlayer..ctor(Int32 device, WaveFormat format, Int32 bufferSize, Int32 bufferCount, BufferFillEventHandler fillProc) in C:\Temp\wavplayer\cswavplay\WaveOut.cs:line 148
at cswavplay.MainForm.Play() in C:\Temp\wavplayer\cswavplay\MainForm.cs:line 182
at cswavplay.MainForm.PlayButton_Click(Object sender, EventArgs e) in C:\Temp\wavplayer\cswavplay\MainForm.cs:line 231
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at cswavplay.MainForm.Main() in C:\Temp\wavplayer\cswavplay\MainForm.cs:line 133
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The file plays correctly in my windows media player (11.0.6001.6336).
Incidently the file I tried was chimes.wav found in the windows\media folder (although it happens with all files I try).
I'm running on Windows Server 2008 RC0 x64
Any help would be appreated, thanks.
Ps. Before you suggest MediaPlayer in the System.Windows.Media namespace that doesn't work either, you hear no sound but no errors or exceptions, however an entry appears in the windows mixer for the application. Very odd and a little frustrating.
|
|
|
|
 |
|
 |
Hi,
I have searched these articles and googled for hours but have found no clue to this.
I created to build wmv video from bitmaps and uncompressed PCM audio stream. The XML used for SetProfile is attached below. This profile is set up for PCM audio. Otherwise, if I don't set it up that way, the audio stream fails to be written to the WMV.
My challenge is that the resultant WMV file contains UNCOMPRESSED audio.
1. Isn't WriteSample supposed to compress the audio samples I write in?
2. The audio plays but the filesize indicates that the audio is not compressed and file->properties of WM Player shows NO audio codec.
3. I guess the profile XML is for specifying the format of what data will be written using WriteSample but how do you specify how the sample will be compressed?
Thank you in advance.
name="Video"
guid="{045880DC-34B6-4CA9-A326-73557ED143F3}"
description="Use this profile for duel view Commercial clips.">
streamnumber="1"
streamname="Audio Stream"
inputname="Audio"
bitrate="32000"
bufferwindow="-1">
bfixedsizesamples="1"
btemporalcompression="0"
lsamplesize="2">
nChannels="1"
nSamplesPerSec="12000"
nAvgBytesPerSec="24000"
nBlockAlign="2"
wBitsPerSample="16"
codecdata="008800001700001E0000"/>
streamnumber="2"
streamname="Video Stream"
inputname="Video"
bitrate="256000"
bufferwindow="-1">
quality="0"/>
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
dwbiterrorrate="0"
avgtimeperframe="666666">
top="0"
right="640"
bottom="264"/>
top="0"
right="540"
bottom="200"/>
biheight="200"
biplanes="1"
bibitcount="24"
bicompression="WMV1"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
|
|
|
|
 |
|
 |
using(SoundPlayer player = new SoundPlayer(outStream))
{
player.PlaySync();
}
|
|
|
|
 |
|
 |
Well Yes but I Think the Theme was LowLevel! - Works with Mobiles too!
|
|
|
|
 |
|
 |
And... you can specify the wave device to play on, whereas the soundPlayer just plays on the default sound device.
|
|
|
|
 |
|
 |
Only if you are using 16-bit WAVs. It won't play 24-bit WAVs on XP.
|
|
|
|
 |
|
 |
Thank you for this! I'm not too familiar with native APIs, so I plugged in your code to create a little thing that tells me how many minutes have passed on so many minutes to the hour (e.g. 5 turns into 5 minutes, so 4:00, 4:05, etc.).
It's funny, because I found out that there's also the System.Speech class for what I really wanted to do.
Still, it's nice that I can play a sound every X minutes (on the hour) AND say some custom text of whatever I want.
Gustavo
|
|
|
|
 |
|
 |
I am having the apppliation for recording..but i can do recording as start and stop. I want the c#.net code for pause functionallity..if anybody knows please help me out..
i am raj
|
|
|
|
 |
|
 |
Hello,
I have a question about wav using. I am beginner in C#, I never used that language before...
Your code is very interesting, but unfortunally for me, he doesn't give me keys for the problem I have. In fact, I want to create an FFT spectral diagram from a wav file. I find the Exocortex.DSP dll which work fine, but I just need to "transform a wave file in a float tab". I am sure it exists a very simple C# functionnaly to do that, but I can't find it...
Can you help me?
Thanks in advance
Matthieu
|
|
|
|
 |
|
 |
Has anybody ever tried to run this class on Windows Mobile ?
You have to change winmm.dll to mscorlib.dll then it should work.
But it doesn't.
After some time of looping a short wave (22050hz, 8Bits, mono):
When I click on "start" (sometime the sound becomes first "strange" before the exeption occures , what seems to me like overwritten unmanaged memory. )
-> System.ArgumentException" in mscorlib.dll
System.ArgumentException: ArgumentException
at System.PInvoke.EE.Runtime_InteropServices_GCHandle_InternalGet()
at System.Runtime.InteropServices.GCHandle.get_Target()
at WaveLib.WaveOutBuffer.WaveOutProc()
A strange Bug, my code and this Code seems to me al right. I really don't know why this happens.
After installing ".net compact framework service pack 2" I can debug is at least, prior that Visual Studio crashed while debugging.
My Code is simple:
--- Snip ---------
void OnPlayNewData(IntPtr data, int size)
{
byte[] tmpData = new byte[size];
if ((_waveData.Position + size) >= _waveData.Length)
{
_waveData.Seek(0,SeekOrigin.Begin); //loop
}
_waveData.Read(tmpData, 0, size);
Marshal.Copy(tmpData, 0, data, size);
}
private void button1_Click(object sender, EventArgs e)
{
WaveLib.WaveStream tmpStream = new WaveLib.WaveStream("/debug.wav");
byte[] buff = new byte[tmpStream.Length];
tmpStream.Read(buff, 0, Convert.ToInt32(tmpStream.Length));
_waveData.Write(buff, 0, Convert.ToInt32(tmpStream.Length));
_player = new WaveLib.WaveOutPlayer(-1, _format, 40 * 160, 3,
new WaveLib.BufferFillEventHandler(OnPlayNewData));
}
--- Snip----
|
|
|
|
 |