Using After Effects expressions to trigger an audio file - audio

Is there a way to trigger an audio file to play in the After Effects timeline when a layer has visible content.
It's a small click sound and when the text layer IN point is reached, I simply want the click wav file to play. Any help would be appreciated.

You have to use scripts to change anything other than keyframe-able layer and effect parameters. You might be able to fake a "click" effect with an expression by triggering a momentary change in the volume of a constant noise audio layer, and using markers to trigger it.
I think using the start times of other layers is problematic because writing an expression that would check any number of layers would involve some kind of for-loop that could get complicated, and you can't easily pass values or variables among different expressions. The question with expressions in AE is always whether the solution saves you time in the long run over just doing it manually, so it depends on your needs.
The quickest way to do it would probably be to just pre-comp your sound effect and whatever layer it needs to match, so that each time the pre-comp plays, you also get the click.

try pressing period(.) After effects dosent let you listen to audio while scrubbing, due to the fact your not looking at the true frame rate. So if you click RAM Preview and play you timeline you will hear you audio files. But for your instance if you press period(.) it will override and play your audio file. I use it when placing a small accent or foley sound.

Related

How to decrease pitch of audio file in nodejs server side?

I have a .MP3 file stored on my server, and I'd like to modify it to be a bit lower in pitch. I know this can be achieved by increasing the length of the audio, however, I don't know of any libraries in node that can do this.
I've tried using the node web audio api, and soundbank-pitch-shift, but the former doesn't seem to have the capabilities of pitch shifting (AFAIK), and the latter seems designed toward client
I need the solution within the realm of node ONLY- that means no external programs, etc., and it needs to be automated as well, so I can't manually pitch shift.
An ideal solution would be a function that takes a file/filepath as an input, and then creates (or overwrites) another MP3 file but with the pitch shifted by x amount, but really, any solution that produces something with a lower pitch than the original, works.
I'm totally lost here. Please help.
An audio file is basically a list of numbers. Those numbers are read one at a time at a particular speed called the 'sample rate'. The sample rate is otherwise defined as the number of audio samples read every second e.g. if an audio files sample rate is 44100, then there are 44100 samples (or numbers) read every second.
If you are with me so far, the simplest way to lower the pitch of an audio file is to play the file back at a lower sample rate (which is normally fixed in place). In most cases you wont be able to do this, so you need to achieve the same effect by resampling the file i.e adding new samples to the file in between the old samples to make it literally longer. For this you would need to understand interpolation.
The drawback to this technique in either case is that the sound will also play back at a slower speed, as well as at a lower pitch. If it is a problem that the sound has slowed down as well as lowered in pitch as a result of your processing, then you will also have to use a timestretching algorithm to fix the playback speed.
You may also have problems doing this using MP3 files. In this case you may have to uncompress the data in the MP3 file before you can operate on it in such a way that changes the pitch of the file. WAV files are more ideal in audio processing. In any case, you essentially need to turn the file into a list of floating point numbers, and change those numbers to be effectively read back at a slower rate.
Other methods of pitch shifting would probably need to involve the use of ffts, and would be a more complicated affair to say the least.
I am not familiar with nodejs I'm afraid.
I managed to get it working with help from Ollie M's answer and node-lame.
I hadn't known previously that sample rate could affect the speed, but thanks to Ollie, suddenly this problem became a lot more simple.
Using node-lame, all I did was take one of the examples (mp32wav.js), and make it so that I change the parameter sampleRate of the format object, so that it is lower than the base sample rate, which in my application was always a static 24,000. I could also make it dynamic since node-lame can grab the parameters of the input file in the format object.
Ollie, however perfectly describes the drawback with this method
The drawback to this technique in either case is that the sound will
also play back at a slower speed, as well as at a lower pitch. If it
is a problem that the sound has slowed down as well as lowered in
pitch as a result of your processing, then you will also have to use a
timestretching algorithm to fix the playback speed.
I don't have a particular need to implement a time stretching algorithm at the moment (thankfully, because that's a whole other can of worms), since I have the ability to change the initial speed of the file, but others may in the future.
See https://www.npmjs.com/package/audio-decode, https://github.com/audiojs/audio-buffer, and related linked at bottom of audio-buffer readme.

Signal/Sound Processing: Making text vibrate to music

I'm working on a simple music visualization. Probably not relevant, but I am doing the sound processing using the new WebKit Audio Data API and the dsp.js library.
I want to make a text vibrate (grow/shrink) to the rhythm of the music. What is the best way to do this?
What I've done so far is ran the signals through a FFT. I look at the bottom 10% of frequencies (bass notes?) and when the amplitude surpasses a certain threshold, I animate the text.
Does this sound right? Or am I completely off?
You say you've done it, and then you ask if you are way off? Well, you tell us: does it work for your application?
One potential problem is that the FFT is slow, both in that there may be a lag between your input and output and there will be a lot of CPU used. I don't expect this will matter for your application, but, in general, you are better off using a low-pass filter. When the output of the low-pass goes above some level, you can use that to trigger something for some short amount of time.
Another issue is simply that this is only a very basic beat detection algorithm. It might work for bass-heavy "four on the floor" music, but you'll need to figure out where the threshold goes and how to keep it moving when the bass stops or something. You may want to research beat detection algorithms. The open source aubio has some.
http://aubio.org/

What is the best way to remove the echo from an audio file?

I want to run an audio file through something like skype's echo cancellation feature. iChat and other VoIPs have this feature too, but I can't find any software that I can import or open my file into.
basic approach:
determine the delay. determine the amplitude offset.
invert the signal. apply the delay. adjust the amplitude. play back both audio files.
any multitrack audio app is capable of this (e.g. audacity, protools, or logic).
for more complex signals, you will need to be more smart about your filtering, and ideally you would suppress the signals before they interfere (in a Skype scenario).
Sounds cool, and makes a lot of sense theoretically, but I still don't really know how I should go about doing it. I am fairly experienced with Logic, but I don't know how to determine the delay. Should i just make a copy of the file, invert it and move it around until it sounds good?
Just line up the transients of the 2 signals visually to determine the delay. Then you have to zoom way in and determine the delay to the sample to achieve the best cancellation. If it's not close, it won't cancel but add.
What do you mean by amplitude offset, is that the volume difference between the original and the echo noise?
Exactly. Apart from very unusual cases, the echo is going to be a different (typically lower) amplitude than the source, and you need to know this difference to cancel it best (this offset is applied to the inverted signal, btw). If the amplitude is wrong, then you will introduce the inverted signal (audibly) or, in the odd event the echo is louder than the source, reduce only part of the echo.
Once the transients are aligned (to the sample) and the signal's inverted, then determine the difference in volume -- if it's too high or too low, it won't cancel as much as it could.
Again, that's a basic approach. You can do a lot to improve it, depending on the signals and processors you have. In most cases, this approach will result in suppression, not elimination.
In order to remove echo, you need TWO files: mic & reference.
The mic is the signal that contains the echo.
The reference is the signal that contains the original audio that generated the echo.
After you have both these files You can start building the logic of echo removal. Start with the wiki page on the subject.

Altering default DirectSound audio renderer buffer size

I've implemented a custom "sample grabber" filter for DirectShow. I grab samples with my host app, perform an FFT on it, and display the results via Direct3D.
The problem is there is nearly a 1 second delay between my visual result and when I hear the audio (the data is visualized before I hear it).
I've looked into it and the reason is that the default audio renderer has an internal one second buffer, as stated by this guy. He states that implementing either IAMBufferNegotiation or IAMPushSource should solve the problem. I have tried both and neither seem to make a difference.
I was curious if anyone else has had the same problem, and I want to make sure there is no other (easy) solution before I write my own audio renderer.
ALL input is appreciated!
Instead of changing the audio renderer filter's internal buffer size, you have to synchronize your drawing (rendering the result) with sample time stamps of the buffer that you calculated the FFT. You can use IReferenceClock::AdviseTime for the synchronization.

Touchscreen using sound input?

i don't really know if it is actually possible, but i believe that it can be made. How possible is it to make a program that recognizes different sound bouncing from the screen and turn it into a position that will obviously be later fed to the mouse.
I know that it sounds kind of dumb, but lately i've been noticing that a very dull, strong sound is made when touching the screen, and that sound varies when doing so at different positions. Probably the microphone "hears" differently because the screen acts as a drum with the casing. Anyways, what do you think, anyone has any experience programming with sound?
First of all most domestic touch screens work by detecting pressure based on a criss-cross mesh layer underneath the display layer.
However I have seen an example where a touch interface was interrogated onto a pane of glass, it used 4 microphones to determine the corners, when you tapped a certain part of the screen it measures the delay in the sound getting to each microphone, therefore allowing one to triangulate the touch.
This is the methodology you would use, you don't even need to set up the hardware to test it, you could throw up an interface in VB, when you click in a box it sends out a circular wave and just calculate using the times it takes to reach the 4 points where the pointer is.
EDIT
As nikie suggested, drag & drop, or any kind of gestures would be impossible using the microphone method, as the technique needs a wave of sound to detect the input.
http://computer.howstuffworks.com/question7161.htm
I don't know if this will get you far, but you can investigate the techniques used in MIDI drums for returning various nuances of play.

Resources