|
isnt there anybody who knows how to do this? it is very important and urgent for me
|
|
|
|
|
Hi
Please let me to ask my problem from you.
I want to record user's sound. may be there are several codes to do this.
But I want that my program create blank wave file and then open Windows Sound Recorder that record sound on that blank file.
Openning Sound recorder is easy :
<br />
Using System.Diagnostics;<br />
Process.Start("sndrec32.exe");<br />
How can i create blank file and enforce Sound Recorder to use that file.
Please Help me
Thank You.
-- modified at 5:29 Saturday 28th January, 2006
|
|
|
|
|
Your only bet is finding command line parameters for sndrec32.exe to do that..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello Again.
NoBody helped me, But I found my answer myself and I want to share it with everbody.
<br />
using System.Diagnostics;<br />
using System.IO;<br />
Now use this :
<br />
Process.Start("sndrec32","C:\\File1001.wav") ;<br />
Or this :
(I Created new blank Wave File and enforced Sound Recorder to Play it
<br />
string strFilePath="C:\\" + "File1002" + ".wav" ;<br />
File.Create(strFilePath) ;<br />
ProcessStartInfo startInfo = new ProcessStartInfo("sndrec32.exe");<br />
startInfo.Arguments = strFilePath ;<br />
Process.Start(startInfo);<br />
Use it and enjoy!
-- modified at 5:18 Sunday 29th January, 2006
|
|
|
|
|
Hi,
Its giving me a Error like "Can't Open File c:\file001.wav"
I tried both methods of doing that... but both methods are showing me same error..
One more quest abt is how to Record the Sound.. ie process.Start(...) is responsible for opening soundRecord exe after that how to press "Record" button programmatically...
Send me ur suggesstions
|
|
|
|
|
You got problem beacause the file is not exist or its already open !
Use this :
<br />
string strFilePath = @"C:\" + "file1001" + ".wav" ; <br />
FileStream waveFile = File.Create(strFilePath) ;<br />
waveFile.Close() ;<br />
Process.Start("sndrec32",strFilePath) ;<br />
It worked on my system.
|
|
|
|
|
Hey everybody
I'm trying to write a program that will check if my disc-on-key is connected or not. I tried to use the "printer usb connected checker" article as an example, but it doesn't work. can anyone at least give me a small hint on how do I check if a disc-on-key has been connected?
I also thought of checking any changes in the number of drives, but I'm looking for a more elegant way.
Thanks Alot!!!!
|
|
|
|
|
Hi All !!! There are some Projects using NumericUpdown from NumericUpdown Screen without using arrows, moreover there is not any hidden layer too. cause should u set a number with 3 digit the 3.rd digit continous working. The thing I wonder is that is that a new control or a code. Can someone give me some clueas about it.I am really Puzzled. A .Net Vb Or C# code would be enough.
|
|
|
|
|
Hi all,
I "add" a wav file to my project "file.wav" and made it embedded resource.
now i have seen here and micosoft code to read and play it but
its not working..what am i doing wrong?
my code:
private byte[] m_soundBytes;<br />
<br />
private enum Flags<br />
{ <br />
SND_ASYNC = 0x0001, <br />
SND_MEMORY = 0x0004, <br />
}<br />
[DllImport("winmm.dll",CallingConvention = CallingConvention.Winapi)]<br />
static extern int PlaySound(byte[] wfname,int hMod,int sf);<br />
then there is the class WSounds:
<br />
public WSounds(string s)<br />
{<br />
string sss = Assembly.GetExecutingAssembly().GetName().ToString();<br />
Stream a = Assembly.GetExecutingAssembly().GetManifestResourceStream(sss + "." + s);<br />
m_soundBytes = new byte[a.Length];<br />
a.Read(m_soundBytes, 0, (int)a.Length);<br />
}<br />
<br />
<br />
public void Play()<br />
{<br />
PlaySound(m_soundBytes, 0, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY));<br />
}<br />
this line throws exception : m_soundBytes = new byte[a.Length];
so i guess something with the resource is wrong..
i tried another code too:
<br />
System.IO.Stream strTheme = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("file.wav");<br />
byte[] bytTheme = new byte[strTheme.Length];<br />
strTheme.Read(bytTheme, 0, (int) strTheme.Length);<br />
<br />
by the way: how do i need to add a WAV file ? under resources sub-dir or on the main project?
Thanks in advance,
Ran
R.Z
|
|
|
|
|
I had troubles with exactly this stuff last week.
ranzask wrote: this line throws exception : m_soundBytes = new byte[a.Length];
so i guess something with the resource is wrong..
The Stream a is probably null, because the assembly couldn't fine the resource. "file.wav" won't work either, because you have to prefix the file.wav with the project namespace (at least in VB.Net).
You can do
string[] names = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string name in names){
Debug.WriteLine(name)
} and look for the name you want (this is the way i did it ).
ranzask wrote: by the way: how do i need to add a WAV file ? under resources sub-dir or on the main project?
That doesn't matter. Whatever the folder may be, it doesn't matter for the compiler, just like C# source files.
HTH!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Thanks alot !!
i did it and change my resource name to include the namespace too and it worked
Thanks again.
Ran.
R.Z
|
|
|
|
|
[Marc] wrote: because you have to prefix the file.wav with the project namespace (at least in VB.Net).
You have to do it in C#, too. <smile />
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
ranzask wrote: I "add" a wav file to my project "file.wav" and made it embedded resource.
now i have seen here and micosoft code to read and play it but
its not working..what am i doing wrong?
You could check out my article here[^]
Share and enjoy.
Sean
|
|
|
|
|
i allready saw that , its too complicated for me
but i figured out my mistake.
R.Z
|
|
|
|
|
Hi,
Its very complicated to see the code,, so please post ur sample piece of code, and also post what is the problem u are facing and whts the solun you found.. its useful for all the beginners as well as developers..
Bye
|
|
|
|
|
the final code is:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Diagnostics;<br />
using System.Threading;<br />
using System.IO;<br />
using System.Reflection;<br />
namespace yournamespace<br />
{<br />
public class WSounds<br />
{<br />
private byte[] m_soundBytes;<br />
private bool disable=false;<br />
private enum Flags<br />
{ <br />
SND_ASYNC = 0x0001, <br />
SND_MEMORY = 0x0004 <br />
}<br />
[DllImport("winmm.dll",CallingConvention = CallingConvention.Winapi)]<br />
static extern int PlaySound(byte[] wfname,int hMod,int sf);<br />
<br />
public WSounds(string s)<br />
{<br />
if (s == null)<br />
{<br />
disable = true;<br />
return;<br />
}<br />
<br />
try<br />
{ <br />
Stream a = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(s);<br />
m_soundBytes = new byte[a.Length];<br />
a.Read(m_soundBytes, 0, (int)a.Length);<br />
}<br />
catch (Exception e) { disable = true; }<br />
}<br />
public void Play()<br />
{<br />
if (!disable)<br />
PlaySound(m_soundBytes, 0, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY));<br />
}<br />
}<br />
<br />
<br />
}<br />
then in your main code you must add a file to your resources list "file.wav" for example that will be along the classes..and change his property to :"embedded resources" so it will compile him along with the exe.
and you call the class this way:
<br />
private WSounds ws;<br />
<br />
ws = new WSounds("yournamespace.file.wav");<br />
<br />
ws.Play();<br />
thats it.
R.Z
-- modified at 6:05 Monday 30th January, 2006
|
|
|
|
|
Hello is there a way to Use the DirectX Api to encode MPEG2 files from a capture card using c#
Any help would be great --
Thanks in Advance
|
|
|
|
|
I new to c# but I am having a lot of fun with it. But there are a couple of thing that I am trying to do, but have not found the solution to.
I want to make a window that should be “glued” to the top and the middle of the screen. It should have an “always on top” function. And when I do not point my mouse over it, it should “slide away” after a certain delay (the only ting I shall be able to see is a progress bar). When I move my mouse over it again, the window should “slide out” again (like a drawer)
Does anyone knew of a component that could do this or is there any other way ?.
|
|
|
|
|
Hi,
I tried to create a web services and the button OK is not active.
I have write to write on that directory. So what it mist there?
Thanks
Gregoire
|
|
|
|
|
What do you mean by the OK button is not active ? Web Service creates a service, there is no user interface or OK button associated with it. Please be more specific.
Simon
|
|
|
|
|
Hi,
I wasn't able to find any posts about this so hopefully this is the first.
I'm trying to use Single.Parse() in .net 2.0 to parse "99.5E-1". However, after it parses the float value is 9.949999998... etc. Why does it do this, and not have it as 9.95?
Thanks,
Stephen
|
|
|
|
|
atanamir wrote: However, after it parses the float value is 9.949999998... etc. Why does it do this, and not have it as 9.95?
Limitations in internal representation of the number.
As you already know, a computer can only deal with ones and zeros. So to represent a floating point number the computer splits the binary into a mantissa (the actual digits) and exponent (position of the point) - this effectively places a virtual dot in the binary.
If you assume the following is 16 bits (5 for the exponent which is set to 00100 [4])
BIN: 0001.1000000 == DEC 1.5
BIN: 1001.1000000 == DEC 9.5
BIN: 1001.1100000 == DEC 9.75
BIN: 1001.1110000 == DEC 9.875
BIN: 1001.1111000 == DEC 9.9375
BIN: 1001.1111100 == DEC 9.96875
BIN: 1001.1111010 == DEC 9.953125
BIN: 1001.1111001 == DEC 9.9453125
Anyway, you can continue refining the value to as close to 9.95 as you can until you hit the 32 bit limit of a single, but you get the idea that in a binary representation 9.95 isn't going to get hit exactly.
If you absolutely must be able to represent 9.95 with no rounding errors like this (for example, because it is an accountancy package) then I recommend using a decimal which is explicitly designed for handling money.
DISCLAIMER: It has been almost 15 years since I last had to do a calculation like this so there may be errors in the detail, but the general concept is the same
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi,
Thanks for the reply;
Yeah i was thinking about using a double or decimal value for this; but I am writing a compiler which has REAL and LONGREAL, hence i was trying to use float. I tried this in code:
float n = 99.5E-1F;
Console.Writeline(n);
that comes out as 9.95.
Infact, I just tried hard-coding this in:
object n = Single.Parse("99.5E-1");
Console.Writeline(n);
it will still come out as 9.95. However, I have following:
class Token {
object _val;
}
If I store the value in there, it gets transformed to 9.949999....
Am i not supposed to cast it into object?
Thank you for your time
Stephen
|
|
|
|
|
Hi,
I have a problem with app.config file.
I put a connection string inside and I tried to retrieve the information in my application in the constructor form , after InitializeComponent().
If I am using:
string ConnString =
System.Configuration.ConfigurationSettings.AppSettings["ConnectionStringSVH"];
ConnString is null after execurion.
If I’am using:
system.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
ConnString=((string)(configurationAppSettings.GetValue("ConnStringSVH", typeof(string))));
I got the exception: {"The key 'ConnString' does not exist in the appSettings configuration section." }
I realize that if I put in Debug directory the config file will be deleted when I run in debug the application.
Any thought?
P.S.1. I rename the config file and put the name of myapp.config
2. I have several project in the same solution Is just in the last one that it didn’t work.
Thanks
Gregoire
|
|
|
|
|
gregoire.b wrote: P.S.1. I rename the config file and put the name of myapp.config
Your project solution should contain the file named as app.config. When it gets copied to the output directory (debug or release), then the file gets renamed as myapp.config. You don't/shouldn't do this manually.
How does "ConnectionStringSVH" look in the app.config file?
Michael
CP Blog [^] Development Blog [^]
|
|
|
|