|
Ok, I have looked a little more at your article. The Marshalling and pinning of the memory is something that I dont work with much. However, it does make sense with the type of memory error that I am receiving.
So, from the original code I posted, how would you maybe suggest I change the stuct, DllImport, and calling methods to be in line with the Marshalling, pinning, and GCHandle? Would the parameter types change?
|
|
|
|
|
You now have published two code snippets, I don't know which one you're talking about right now.
However this is what I would to:
1.
on the former snippet, take my advice, i.e. apply the third method of passing an array (with GCHandle, without Marshal, without unsafe). I expect that to work perfectly right away. And it does not require any change on the native side.
2.
on the latter snippet, if the former now works well and you see sufficient reason to modify the latter, modify it to better correspond to the former.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry for the latter code. Please ignore it. Maybe I can delete it.
|
|
|
|
|
econner wrote: Any suggestions would be appreciated.
Don't embed it in in your C#/.Net code.
Instead wrap it in a C++ executable with a communication (socket/file/stdio) API and run it from C# via Process and write C# code to talk to the communication API.
The advantage is that it can't take down your C# app and you can test the parts independently.
Note the first part as that can happen even if your code is perfect if there is a bug in the library itself.
|
|
|
|
|
Hello everyone,
i wan't to create something like a active noise cancellation system . So i want to record audio with a mic in c# and modify the signal, that i get the "negative" or opposite signal and play that negative signal of the ingoing signal.
I've never recorded any audio and don't understand, what i get in such a recorded stream. Do i get simple integer values, which i only need to opposite (value * -1) and write them to another stream and put them through or what do i need to do?
|
|
|
|
|
Hmm. Good luck!
Firstly, if you get and audio stream there are many different encodings it could come in. Probably the most common would be 44.1KHz 16 bit. So you'd be dealing with buffers of shorts.
Obviously, if you negate this signal and add this to the original, everything cancels out and you end up with silence, so I suspect what you want to do is use two input signals, a reference one, and a background one.
Now, because the mics will be in different positions, you'll likely get a phase shift and this will vary depending on the frequency composition of what you're recording. You could actually end up boosting a signal rather than cancelling it if you phase is shifted 180 degrees.
I would imagine an effective way to do this is firstly to translate the signal from the time domain to the frequency domain, then compare and adjust the amplitude of the frequency bands, and convert it back again. This involves heavy duty mathematics. Lower frequencies are easier to cancel than higher ones as you may have observed if you have some noise cancelling headphones.
Scary stuff, and with the best of respect unless you're well versed in the field of digital signal processing I'd consider doing something else.
Regards,
Rob Philpott.
|
|
|
|
|
If all you want to do is change the phase of your audio signal, you don't need a computer or an app, all it takes is swapping the wires to the speaker!
However, noise, by its very definition, is a random signal; meaning whatever it is you capture with a MIC is a thing of the past and will sound like, but be far from identical to, the noise you will encounter later. Cancellation by adding something works fine on predictable sounds, such as the (50Hz or so) rumble of an engine; noise cancellation normally is done through filtering, not by addition.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sincerely, I don't know. You might begin by searching for "computational harmonic analysis" and "Fourier transform"... and good luck.
|
|
|
|
|
A simple method (for sine wave signals or predictable noise) is to simply invert the signal and play back at point of origin.
This is used in engine noise reduction systems and in top-end industrial machinery.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Exactly that is what i want to do!
I know, that callibration of that isn't simple and so on, but i want to try it.
If it would be easy, it would by uninteresting.
So how can i record audio from a microphone and simply invert the signal and put it out over my speakers?
|
|
|
|
|
Well, I think that making a noise cancellation system can be a bit more complex than just taking the opposite of the sound samples (depending on what you are trying to do).
Typically, sound signals are represented as arrays of either integer of floating point values, also known as samples. There are many ways to represent an audio sample, but the floating point representation usually works best since it results in less loss of precision during processing since it tends to attenuate quantization issues.
Good reading material is available in Wikipedia, here[^], here[^] and here[^]. A few years ago I have also written an example on how to record an audio signal from the microphone in C# using SlimDX.[^]. I hope it helps (at least to get started with audio processing).
Best regards,
Cesar
|
|
|
|
|
Hi ,
I am try to make my connection string dynmic with th current root when i run my app in any location.
in web I am the path as the following : DataDirectory/mydb.mdf
but when i am try to make that in Machine Config (Win App) but not work.
How I can do something like that ?
|
|
|
|
|
|
|
Honeyboy_20 wrote: Connection string Path ?
As i getting your question you want know about ConnectionString path in .Config file for Windows Application. if so then see what I get after connecting Database to my Application.[It automatically Generate]
<connectionStrings>
<add name="WindowsApplication1.Properties.Settings.Database1ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
in short I get for ConnectionString Path
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
Let me know in case of any problem.
|
|
|
|
|
|
Honeyboy_20 wrote: I do that but not work.
are you getting any exceptions is so please mention it.
Hope I will able to solve it ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
You can get the location/path of the dll using the AppDomain.
Then you create a fully defined path from that and your database name.
|
|
|
|
|
hey guys..i have to add 19 icons to my form..but i dont know which tool i should use?..19 picturebox i should add to my form or one another tool can i use ?
vemedya.com
|
|
|
|
|
Draw them yourself in the Paint event:
private void MyForm_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(myIcon, myIconLocation);
...
}
For details see http://msdn.microsoft.com/en-us/library/42807xh1.aspx[^]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
thanks for the help..should i add them to resources File of my project..to use them when i make its exe ?
vemedya.com
|
|
|
|
|
erdinc27 wrote: should i add them to resources File of my project
If they are fixed when you compile, then yes, it reduces the amount of stuff you need to ensure is there when your app runs..
If not, then keep them as files and load them when your form loads, or when they change.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
ok friend..thanks for your help and time
vemedya.com
|
|
|
|
|
Welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|