View Full Version : Producing a Specific frequency for set time (ms), how?
Adub
2nd March 2007, 21:50
Hey guys!
Here is a small, odd question.
Is it possible to right a script using Avisynth that will produce a certain sound, or actually a specific frequency for a time period measured in miliseconds.
Prior to this, I need to send some sort of trigger signal that will enable a DAQ card (data aquisition card).
So, in this order
x=trigger
z=frequency
x (triggers card to begin data aquisition) -> the specified frequency is sent (z).
I know that this is probably a relativily easy script, but I just don't know how to do it.
Anyhelp would be appreciated.
gzarkadas
2nd March 2007, 22:12
Use the Tone standard filter for the frequency.
For the DAQ card, you must specify the interface in order to be able to provide any help, if possible.
For example, is it a port-driven card? (You will need low level port-I/O if this is true.) How is it connected to the PC? What signals does it accept?
Adub
3rd March 2007, 00:53
Okay, the DAQ is connected to the PC via a PCI slot.
It is an Adlink PCI-9118, DG/L, HG/L, HR/L DAQ.
However, the card is not really my problem/question.
Oh, and I found the Tone() function. I think that I know enough Avisynth in order to do what I ask.
The initial frequency is sent, followed by the desired frequency in a given time interval.
Just for giggles, is there and easy way to have the signal duplicate, or rather, repeat itself without my pressing ctrl-C an bunch of times to paste the aligned splice arguments?
My script looks something like this:
a=Tone(.03,500,48000,1) #Output Frequency
b=a.amplify(0.0) #Silence
c=Tone(1, 445,48000,1) #Trigger Frequency
c ++ a ++ b ++ a ++ b ++ a ++ b..........
I am not quite sure how many times we are going to want it to repeat, but that can be adjusted later.
IanB
3rd March 2007, 06:38
...
C ++ Loop(A ++ B, 123) # 123 times
Adub
3rd March 2007, 20:00
Ohhhhh, okay.
Thanks IanB. I didn't know about the loop function. This should work nicely now.
Adub
6th March 2007, 20:15
Okay, another question.
Can I easily give the output signal a Guassian shape or should I through together a combination of frequencies to force one?
I looked, and unfortunately there is no option for providing a Gaussian form in the "type" variable of the Tone() function. Kind of a shame.
gzarkadas
7th March 2007, 00:28
Okay, another question.
Can I easily give the output signal a Guassian shape or should I through together a combination of frequencies to force one?
I looked, and unfortunately there is no option for providing a Gaussian form in the "type" variable of the Tone() function. Kind of a shame.
When you say "gaussian shape" you mean on the frequency domain or on the time domain ? In other words, you want a bell of frequencies for a specific time duration or a bell-shaped-one-frequency signal (or maybe a bell on both domains)?
In any case you will have to go through combinations, though. The "type" argument defines the shape of the signal inside one period only, not inside the signal as a whole.
Adub
7th March 2007, 03:15
Yeah, I am talking more about the whole frequency envelope, like this one:
http://www.sfu.ca/sonic-studio/handbook/Graphics/Grain.gif
the bottom one.
However, I think you are right about using the combination of two frequencies. I was messing with it earlier and it turned out pretty well, I was just hoping that their would be a quick shortcut to it.
Thanks, gzarkadas!
foxyshadis
7th March 2007, 03:30
There is: Writing your own tone generator plugin. ;) So far as I know, nothing beyond the BASICA-clone tone() exists currently, but there are a few open source packages that might be cajoled into avisynth plugins.
Adub
7th March 2007, 15:16
One small hole.
I don't know any computer languages! I am still in friggin high school (senior!), but the computer classes hear suck so much, that they completely removed them from the curriculum. Right now, I am just focusing on learning as much Avisynth as I can, as it is a nice, basic language to start out on.
IanB
7th March 2007, 23:04
Okay you want a Gaussian FadeIn/FadeOut.
Sorry only linear fade envelopes are currently implemented. However you could stack several FadeIO0 calls to generate a polynomial approximation. i.e.tone(...)
FadeIO0(10) # Linear
FadeIO0(10) # Square
FadeIO0(10) # Cube
wonkey_monkey
7th March 2007, 23:37
Ian, can you satisfy my curiousity? I just can't work out why that works the way it does. I would have expected applying three fadeios to create a steadily steepening curve that didn't flatten out the way it actually does.
http://img15.imgspot.com/u/07/65/18/fadeios1173310164.png
On top is AviSynth's result of three stacked fadeins, and below is the result of applying three Adobe Audtion fadeins. Where does the difference come from?
David
gzarkadas
8th March 2007, 17:42
Where does the difference come from?
All the Fade... filters use Dissolve internally. Dissolve mixes the two clips in the interval of its action (this includes audio which is the interest of this thread), say [clip1, clip2] having as target to produce clip1 at one end and clip2 at the other.
In our case, the outer end (clip1) is silence and the inner end at frame 10 (clip2) is the constant volume produced by Tone. Thus the result of applying (any number of) Fade... is bounded at constant values and produces the output that you see.
wonkey_monkey
8th March 2007, 18:03
Thus the result of applying (any number of) Fade... is bounded at constant values and produces the output that you see.
The Audition result is also bounded at constant values, but it produces what I'd expect - a steepening curve of the form y=((1/c)x)^n (up to a maximum), with n being the number of fades applied, and c being the number of frames over which the fade is applied.
I'm thinking of each fade as a constantly increasing multiplication from 0 to 1 (since clip1 is silence) - but this must be wrong because AviSynth is producing a flattening curve :confused:
(I should point out that I didn't try to apply the Audition fades over the same time period as the AVS fade above it)
Sorry if I'm derailing the thread!
David
gzarkadas
9th March 2007, 00:08
Sorry if I'm derailing the thread!
Well, you are welcome; the initial questions have been answered, so we need new to continue :D
The Audition result is also bounded at constant values, but it produces what I'd expect - a steepening curve of the form y=((1/c)x)^n (up to a maximum), with n being the number of fades applied, and c being the number of frames over which the fade is applied.
I'm thinking of each fade as a constantly increasing multiplication from 0 to 1 (since clip1 is silence) - but this must be wrong because AviSynth is producing a flattening curve :confused:
I am with you - :confused: - because after inspecting the Dissolve source code I came to believe that it should be producing a similar steepening curve if the dissolve region remained the same in all subsequent calls. Perhaps this is the reason for the behaviour you observed, because from here (http://forum.doom9.org/showthread.php?s=&threadid=72760&highlight=ConvertAudio) (link from the Avisynth Filter SDK) it appears that this is not generally the case. But this is just a hunch; so I leave it to be answered from someone that really knows.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.