Skip to contentSkip to conversation

frequency analysis with alsa and fftw

DISCUSSION Markus Vogl 2 participants 5 messages Dec 27, 2009 – Dec 28, 2009

lore
Share & tools
lore
#0 lore raw

hello,

i´m absolute newbie in programming alsa, but for my school project i have to do so.
my project is to analyse the mic input frequency from my asus eepc 1008ha with ubuntu 9.10 and show it in a terminal window. i would use my acoustic 6 string guitar to play in front of my netbook.

i´ve testet the howto from linuxjornal.com ..
http://www.linuxjournal.com/article/6735

...but i´ve no plan to use the mic input and then analyse it with fftw.

regards
markus

Signature · 2 lines
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser
#1 lore raw
Quoted 8 lines · Markus Vogl

my project is to analyse the mic input frequency from my asus eepc 1008ha with ubuntu 9.10 and show it in a terminal window. i would use my acoustic 6 string guitar to play in front of my netbook.

i´ve testet the howto from linuxjornal.com ..
http://www.linuxjournal.com/article/6735

...but i´ve no plan to use the mic input and then analyse it with fftw.

Why do you need to do ALSA programming in the first place? Isn't it enough to use any given ALSA-capable audio recorder (eg. arecord) to record some sound, convert it to raw PCM data (eg. cut off the WAV header) and then shift all the data into the FFT lib?

MfG, JBG

Signature · 3 lines
      Jan-Benedict Glaw      [email protected]              +49-172-7608481
 Signature of:                            If it doesn't work, force it.
 the second  :                   If it breaks, it needed replacing anyway.

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw

hi,

i have to do this in realtime (like a guitartuner) and with my "project" i have to see the frequency shift in realtime in a terminal window.

regards
markus

-----Ursprüngliche Nachricht-----
Von: Jan-Benedict Glaw [mailto:[email protected]]
Gesendet: Sonntag, 27. Dezember 2009 13:54
An: Markus Vogl
Cc: [email protected]
Betreff: Re: [alsa-devel] frequency analysis with alsa and fftw

Quoted 8 lines · Markus Vogl

my project is to analyse the mic input frequency from my asus eepc 1008ha with ubuntu 9.10 and show it in a terminal window. i would use my acoustic 6 string guitar to play in front of my netbook.

i´ve testet the howto from linuxjornal.com ..
http://www.linuxjournal.com/article/6735

...but i´ve no plan to use the mic input and then analyse it with fftw.

Why do you need to do ALSA programming in the first place? Isn't it enough to use any given ALSA-capable audio recorder (eg. arecord) to record some sound, convert it to raw PCM data (eg. cut off the WAV
header) and then shift all the data into the FFT lib?

MfG, JBG

Signature · 3 lines
      Jan-Benedict Glaw      [email protected]              +49-172-7608481
 Signature of:                            If it doesn't work, force it.
 the second  :                   If it breaks, it needed replacing anyway.
#3 lore raw
Quoted 13 lines · Markus Vogl

Von: Jan-Benedict Glaw [mailto:[email protected]]:

Quoted 12 lines · Markus Vogl
Quoted 10 lines

my project is to analyse the mic input frequency from my asus eepc 1008ha with ubuntu 9.10 and show it in a terminal window. i would use my acoustic 6 string guitar to play in front of my netbook.

i´ve testet the howto from linuxjornal.com ..
http://www.linuxjournal.com/article/6735

...but i´ve no plan to use the mic input and then analyse it with fftw.

Quoted 8 lines
Quoted 4 lines

Why do you need to do ALSA programming in the first place? Isn't it enough to use any given ALSA-capable audio recorder (eg. arecord) to record some sound, convert it to raw PCM data (eg. cut off the WAV header) and then shift all the data into the FFT lib?

i have to do this in realtime (like a guitartuner) and with my "project" i have to see the frequency shift in realtime in a terminal window.

Sure. Just let eg. arecord write to stdout or to a FIFO and read the data from there. You can directly request raw output, all you need to do is to shouvle the data through the FTT lib...

MfG, JBG
PS: I did some clean-up of your TOFU email.

Signature · 3 lines
      Jan-Benedict Glaw      [email protected]              +49-172-7608481
Signature of:                     Eine Freie Meinung in einem Freien Kopf
the second  :                   für einen Freien Staat voll Freier Bürger.

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw
Quoted 36 lines

-----Ursprüngliche Nachricht-----
Von: Jan-Benedict Glaw [mailto:[email protected]]
Gesendet: Sonntag, 27. Dezember 2009 15:05
An: Markus Vogl
Cc: [email protected]
Betreff: Re: [alsa-devel] frequency analysis with alsa and fftw

Quoted 2 lines · Markus Vogl

Von: Jan-Benedict Glaw [mailto:[email protected]]:

Quoted 1 line

On Sun, 2009-12-27 13:26:31 +0100, Markus Vogl

Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
Quoted 1 line

my project is to analyse the mic input frequency from

my asus eepc

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

1008ha with ubuntu 9.10 and show it in a terminal window. i would use my acoustic 6 string guitar to play in front of my netbook.

i´ve testet the howto from linuxjornal.com ..
http://www.linuxjournal.com/article/6735

...but i´ve no plan to use the mic input and then

analyse it with

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

fftw.

Why do you need to do ALSA programming in the first

place? Isn't it

Quoted 2 lines
Quoted 2 lines

enough to use any given ALSA-capable audio recorder (eg. arecord) to record some sound, convert it to raw PCM data

(eg. cut

Quoted 4 lines
Quoted 1 line

off the WAV header) and then shift all the data into the FFT lib?

i have to do this in realtime (like a guitartuner) and with my "project" i have to see the frequency shift in realtime in

Quoted 7 lines

a terminal

Quoted 1 line

window.

Sure. Just let eg. arecord write to stdout or to a FIFO and read the data from there. You can directly request raw output, all you need to do is to shouvle the data through the FTT lib...

Who can me explain how i can transfer the frame/buffer to the fftw3.lib? This is from the howto example at linuxjournal and in the "while loop" is the frame that i can use for DFT ...or i´m wrong?

while (loops > 0) {
    loops--;
    rc = snd_pcm_readi(handle, buffer, frames);
    if (rc == -EPIPE) {
      /* EPIPE means overrun */
      fprintf(stderr, "overrun occurred\n");
      snd_pcm_prepare(handle);
    } else if (rc < 0) {
      fprintf(stderr,
              "error from read: %s\n",
              snd_strerror(rc));
    } else if (rc != (int)frames) {
      fprintf(stderr, "short read, read %d frames\n", rc);
    }
    rc = write(1, buffer, size);
    if (rc != size)
      fprintf(stderr,
              "short write: wrote %d bytes\n", rc);

}

regards
markus