LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-09-2016, 06:47 AM   #1
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Rep: Reputation: Disabled
How to get the frequency plot spectrum of a wav file?


Hi,

I have a wav file with sample rate 48kHz.
In that file I kept a sine tone with 1kHz frequency.

I want to check these using sox or any other utility that was available in the linux.

I used sox file.wav -n stat -freq but I got lots of data which I dont know how to analyze.

Can anyone help me in this
 
Old 06-09-2016, 09:04 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,197

Rep: Reputation: 164Reputation: 164
You need a fast fourier transformation.
 
Old 06-09-2016, 09:07 AM   #3
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
How to get that?
 
Old 06-09-2016, 03:34 PM   #4
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,197

Rep: Reputation: 164Reputation: 164
AVX or AVX2 of modern CPU is FFT.
 
Old 06-10-2016, 01:10 AM   #5
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
When I used this command
sox $1 -n stat -freq 2>&1 | sed -n -e :a -e '1,15!{P;N;D;};N;ba' | gnuplot -p -e 'set logscale x; plot "-" with linesp'

I am getting the plot specturm.
But I want that as a plain text in terminal output.

Is that possible?
 
Old 06-10-2016, 08:54 AM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Just remove the gnuplot & plot commands from the pipe?
 
Old 06-10-2016, 09:47 AM   #7
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
Removing wont solve. It gives a lots of frequency and other output.
But I need the peak frequency
 
Old 06-11-2016, 08:17 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,240

Rep: Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451
Wow, didn't know it could do so much. http://sox.sourceforge.net/sox.pdf

Can't find where sox can find maximum frequency however.

See this maybe. http://superuser.com/questions/43626...-an-audio-file

If you wanted to look at it visually you might be able to use Audacity. https://pantherfile.uwm.edu/type/www...isAudacity.htm
 
1 members found this post helpful.
Old 06-12-2016, 11:39 PM   #9
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi,

I am unable to comment on that link.
Could you please let me know which language it is.
I am using bash for doing my stuff.
How to use that code here.?
Or do i need to change my language?
 
Old 06-13-2016, 07:02 AM   #10
vvn2023
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
I used something in python like
code:

import scikits.audiolab, scipy
import pylab
x, fs, nbits = scikits.audiolab.wavread("capture_smoke_rec_16000_16.wav");
X = scipy.fft(x)
print X


I got this output

[[-0.13085938+0.j 0.00000000+0.j]
[-0.76538086+0.j 0.00000000+0.j]
[-1.41424561+0.j 0.00000000+0.j]
...,
[ 1.84771729+0.j 0.00000000+0.j]
[ 1.41418457+0.j 0.00000000+0.j]
[ 0.76531982+0.j 0.00000000+0.j]]

I dont know how to analyze this one.
I thought I will get 1kHz as the peak frequency.
How to get that
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Install tar.gz file like spectrum login page tlcasey100 Linux - Newbie 5 03-01-2016 01:50 PM
[SOLVED] How to convert Ogg Vorbis .WAV file to normal .WAV file? *Dark Dragon* Linux - Software 8 11-16-2014 01:45 PM
plot trace file into a graph tootz Linux - Software 14 04-26-2012 04:07 AM
.plot file printing Pier Linux - General 0 12-18-2005 04:37 PM
how can i create a simple frequency spectrum from a sound playing like in XMMS dipumurti Programming 1 05-07-2004 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration