0
$\begingroup$

I'm doing a simple mini project on FPGA board, electronic lock which open when a short track (the "password") is play next to the lock's mic.

i want to save samples of the chosen song to an array x[n] and and then take samples from the mic and save them to a FIFO list y[n]. then compare the the conv result z[n]=x[n]*y[n] and when it is big enough the lock is open.

the question is how many samples i need for 3-4 sec of rock song for this purpose?

$\endgroup$
  • $\begingroup$ so you're using a matched filter to open a lock? what is the legitimate user supposed to do to open the lock? playback a sound from their iPod or phone? $\endgroup$ – robert bristow-johnson Nov 5 '15 at 18:02
1
$\begingroup$

The typical audio sampling rate is 44 kHz, so you would need between 130 000 and 175 000 samples. In practice though, it depends on the sampling rate you use on your FPGA. You can lower, but you will need to low-pass your signal before sampling it to avoid aliasing.

Note that if you put a threshold on z[n]=x[n]*y[n], it will not be invariant to volume differences.

$\endgroup$
  • 1
    $\begingroup$ I think it would be better to normalize the signal, then take cross correlation with the reference signal to detect the password in a crude way $\endgroup$ – Vinith Jul 8 '15 at 13:45
1
$\begingroup$

Like another answerer stated, 44.1 kHz is a standard sample rate used (44 kHz is a common "approximation"), such as for CD audio (Red Book standard), so the number of samples would be 44e3*n_seconds.

However, one other consideration is the source sound data-- if it is coming from an mp3 file (or wma, aac, mp4, etc.), the audio is compressed and you would need to have a codec on your board to uncompress it. This might be a lot of work because decoding compressed audio would be harder than your actual project, so you'd need to find someone else's implementation and integrate it into your project. If you had uncompressed audio, like PCM (pulse coded modulation) inside a .wav file container, you could just pull the raw samples directly from the file and play them with out too much hassle.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.