开发者

How to generate dynamic audio signal

开发者 https://www.devze.com 2023-01-10 13:58 出处:网络
I am looking to control some electronic servo\'s using the headphone port as a the control signal.I need to be able to generate a pulse width modulation signal and change the width of the pulse on the

I am looking to control some electronic servo's using the headphone port as a the control signal. I need to be able to generate a pulse width modulation signal and change the width of the pulse on the fly开发者_高级运维 rapidly. I would prefer to do this in C# but can c++ is also an option. Any idea's how to go about doing this?


You can look for how to do a midi output.

I have only done this with C++, so with C# it was with interop, but here is a simple intro to it.

http://midiio.sapp.org/doc/windowsmidi/

Here are some nice answers to a similar question long before SO came onto the scene.

http://www.groupsrv.com/computers/about164021.html


Assuming you are talking about common model radio control servos, you are talking about a positive-going pulse 1-2 msec wide, with a pulse repetition frequency of 20-50 Hz. 1 msec is hard-over left, 2 msec is hard-over right, 1.5 msec is centered. ANY kind of jitter on the pulse train will cause instability in the servo.

That's likely going to be a VERY hard spec to meet on a card designed to emit sound.

You will have a much easier time using an outboard microcontroller to generate your PWM signal, and controlling it through a serial port. Assuming my goal was to get something working quickly, I'd probably use an Arduino board (Atmel ATMega328, on a board that makes hardware hacking very easy).


This looks like it might be what you need:

http://www.codeproject.com/KB/audio-video/CS_ToneGenerator.aspx

(third item from googling "c# dsp tone generator")

Edit: if you need to be able to rapidly change the tone parameters, then you're getting into the realm of software synthesis. There are a number of low-latency (essentially realtime) software synthesizers out there (Reaktor is one I can think of). All of them can manage simple tone generation like what you're after, and most of them can be driven by MIDI (which would make MIDI a viable choice, in contrast to what I just said in a comment to another answer here). MIDI is OK as long as you couple it to a specific tone generator/software synthesizer.


NAudio: http://naudio.codeplex.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消