David Cournapeau | 1 Sep 09:13
Picon

Re: Create a spectrogram from a waveform

On Mon, Sep 1, 2008 at 5:52 AM, Ed McCaffrey <ed <at> edmccaffrey.net> wrote:
> Thanks for the reply.  I had not heard of audiolab before, but I just tried
> using it.
>
> Looking at audiolab made me realize that I had forgotten how a .wav stores
> the data for multiple channels, so that was why the spectrogram I generated
> before looked so odd.

You should not have to care how it is stored, normally. audiolab gives
you one column per channel; audiolab is just a wrapper around sndfile,
which handles interleaving/deinterleaving internally if necessary.

Also, this is not well documented, unfortunately, but if you don:t
have advanced needs, you can use the high level API ala matlab:

from scikits.audiolab import wavread

If you want to compute the spectrogram without matplotlib, this is not
too difficult: a spectrogram is a short time fourier, that is fourier
transform computed on windowed parts of your signal

http://en.wikipedia.org/wiki/Short-time_Fourier_transform

I hope to include a tool for automatically segmenting a signal into a
matrix of overlapping windows (implemented by A. Archibald) into numpy
after 1.2 release. With this, a spectrogram is 2-3 lines away in pure
numpy

cheers,

(Continue reading)

luca.ciciriello | 1 Sep 11:56
Picon
Favicon

install SciPy on Mac OS X 10.4


Hi All.
I've installed NumPy 1.1.1 and now I want to install SciPy 0.6.0 on My Mac
OS X 
(10.4 PPC). I've got scipy-0.6.0.tar.gz.tar from SciPy site. On My system
is installed Xcode 2.5, so my default compiler is gcc 4.0.1. I've read in
INSTALL.TXT in SciPy distribution that SciPy is not so compatible with this
compiler, then to try to digit gcc_select 3.3. 
My question is: where have I to digit this gcc_select 3.3? 

Thanks in advance for any answer.

Luca 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f

 Sponsor:
 Realizza i tuoi sogni con Carta Eureka. Fido fino a 3.000 euro, rate a
partire da 20 euro e canone gratis il 1° anno. Scoprila!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7877&d=20080901
Ed McCaffrey | 1 Sep 13:20
Gravatar

Re: Create a spectrogram from a waveform



On Mon, Sep 1, 2008 at 3:13 AM, David Cournapeau <cournape <at> gmail.com> wrote:
You should not have to care how it is stored, normally. audiolab gives
you one column per channel; audiolab is just a wrapper around sndfile,
which handles interleaving/deinterleaving internally if necessary.

I was referring to earlier, before I used audiolab and got an odd spectrogram.

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
David Cournapeau | 1 Sep 16:23
Picon

Re: install SciPy on Mac OS X 10.4

On Mon, Sep 1, 2008 at 6:56 PM,  <luca.ciciriello <at> email.it> wrote:
>
> Hi All.
> I've installed NumPy 1.1.1 and now I want to install SciPy 0.6.0 on My Mac
> OS X
> (10.4 PPC). I've got scipy-0.6.0.tar.gz.tar from SciPy site. On My system
> is installed Xcode 2.5, so my default compiler is gcc 4.0.1. I've read in
> INSTALL.TXT in SciPy distribution that SciPy is not so compatible with this
> compiler, then to try to digit gcc_select 3.3.

Hm, those informations are really obsolete. Please ignore them, we
should update them.

cheers,

David
Chris Lee | 1 Sep 16:40
Picon
Picon

Re: install SciPy on Mac OS X 10.4

The enthought distro will do all this for you as well. 
(http://www.enthought.com/products/epdacademic.php?ver=MacOSX 
)

Cheers
Chris

On Sep 1, 2008, at 4:23 PM, David Cournapeau wrote:

> On Mon, Sep 1, 2008 at 6:56 PM,  <luca.ciciriello <at> email.it> wrote:
>>
>> Hi All.
>> I've installed NumPy 1.1.1 and now I want to install SciPy 0.6.0 on  
>> My Mac
>> OS X
>> (10.4 PPC). I've got scipy-0.6.0.tar.gz.tar from SciPy site. On My  
>> system
>> is installed Xcode 2.5, so my default compiler is gcc 4.0.1. I've  
>> read in
>> INSTALL.TXT in SciPy distribution that SciPy is not so compatible  
>> with this
>> compiler, then to try to digit gcc_select 3.3.
>
> Hm, those informations are really obsolete. Please ignore them, we
> should update them.
>
> cheers,
>
> David
> _______________________________________________
> SciPy-user mailing list
> SciPy-user <at> scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

***************************************************
Chris Lee
Laser Physics and Nonlinear Optics Group
MESA+ Research Institute for Nanotechnology
University of Twente
Phone: ++31 (0)53 489 3968
fax: ++31 (0)53 489 1102
***************************************************
Jeff Lyon | 1 Sep 17:41
Picon

Re: Create a spectrogram from a waveform

Hello,

I tried to run the spectrogram.py example and I appear to be having configuration problems. I have installed the latest enthought distro, but the enable module can seem to find it's api component. Any thoughts?

~ jeff$ python
Enthought Python Distribution (2.5.2001) -- http://code.enthought.com

Python 2.5.2 |EPD 2.5.2001| (r252:60911, Jul  1 2008, 19:18:12) 
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import spectrum.py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "spectrum.py", line 19, in <module>
    from enthought.enable.api import Window
ImportError: No module named api


Thanks,
Jeff Lyon


On Aug 30, 2008, at 6:28 PM, Peter Wang wrote:

Quoting Ed McCaffrey <ed <at> edmccaffrey.net>:

I wrote a program in C# that creates a spectrogram from the waveform of a
.wav music file.  I now want to port it to Python, and I want to try to use
SciPy instead of a direct port of the existing code, because I am not sure
that it is perfectly accurate, and it is probably slow.

I am having a hard time finding out how to do this with SciPy.  With my
code, I had a FFT function that took an array of real and imaginary
components for each sample, and a second function taking both that produced
the amplitude.  The FFT function in SciPy just takes one array.

Has anyone done this task in SciPy?

We have a realtime spectrogram plot in the Audio Spectrum example for  
Chaco.  (See the very last screenshot on the gallery page here:  
http://code.enthought.com/projects/chaco/gallery.php)

You can see the full source code of the example here:
https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/advanced/spectrum.py

The lines you would be interested in are the last few:

def get_audio_data():
    pa = PyAudio()
    stream = pa.open(format=paInt16, channels=1, rate=SAMPLING_RATE,
                     input=True,
                     frames_per_buffer=NUM_SAMPLES)
    string_audio_data = stream.read(NUM_SAMPLES)
    audio_data  = fromstring(string_audio_data, dtype=short)
    normalized_data = audio_data / 32768.0
    return (abs(fft(normalized_data))[:NUM_SAMPLES/2], normalized_data)

Here we are using the PyAudio library to directly read from the sound  
card, normalize the 16-bit data, and perform an FFT on it.

In your case, since you are reading a WAV file, you might be  
interested in the zoomed_plot example:  
http://code.enthought.com/projects/chaco/pu-zooming-plot.html

This displays the time-space signal but can easily be modified to show  
the FFT.  Here is the relevant code that uses the built-in python  
'wave' module to read the data:  
https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/zoomed_plot/wav_to_numeric.py

You should be able to take the 'data' array in the wav_to_numeric  
function and hand that in to the fft function.


-Peter

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Picon

matplotlib - axis and zoom

Hi Guys,

how can I maintain zoom in the horizontal axis and keep the vertical 
axis unchanged using the zoom tool provided by matplotlib?

Bernardo M. Rocha
Robert Cimrman | 2 Sep 14:14
Picon

ANN: SfePy-00.50.00

I am pleased announce the release of SfePy 00.50.00.

SfePy is a finite element analysis software in Python, based primarily
on Numpy and SciPy.

Mailing lists, issue tracking, mercurial repository: http://sfepy.org
Home page: http://sfepy.kme.zcu.cz

People who contributed to this release: Ondrej Certik, Ryan Krauss, 
Vladimir Lukes.

Major improvements:
- finite strain elasticity: neo-Hookean, Mooney-Rivlin materials in the 
total Lagrangian (TL) formulation
- solving problems in complex numbers
- generalized equations to allow linear combination of terms
- run-time type of state term arguments
- refactoring to follow Python coding style guidelines
- new terms

For more information on this release, see
http://sfepy.googlecode.com/svn/web/releases/005000_RELEASE_NOTES.txt

Best regards,
Robert Cimrman
Favicon

Arrays and strange memory usage ...

Hi,

I have a application that is very demanding in memory ressources. So I
started to to look closer at python + numpy/scipy as far as memory is
concerned. 

I can't explain the following :

I start my python, + import scipy. A 'top' in the console shows that :

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME COMMAND
14791 grimault  20   0 21624 8044 3200 S    0  0.4   0:00.43 python

Now after typing :

z = scipy.arange(1000000)

I get :
14791 grimault  20   0 25532  11m 3204 S    0  0.6   0:00.44 python

So the memory increased by ~ 7 Mb. I was expecting 4 Mb since the data
type is int32, giving 4*1000000 = 4 Mb of memory chunk (in C/C++ at
least).

It gets even worse with complex float. I tried : 
z = arange(1000000) + 1j*arange(1000000)

Expecting 8 Mb, since z.dtype gives "complex64", the "top" shows an
increase by 31 Mb.

This is very annoying. Can someone explain this ? Is there a way to
create numpy arrays with the same (approximately ! I know the array
class adds some overhead...) memory footprint as in C/C++ ?

Thanks in advance
Robert Kern | 2 Sep 21:10
Picon
Gravatar

Re: matplotlib - axis and zoom

On Tue, Sep 2, 2008 at 04:47, bernardo martins rocha
<bernardo.rocha <at> meduni-graz.at> wrote:
> Hi Guys,
>
> how can I maintain zoom in the horizontal axis and keep the vertical
> axis unchanged using the zoom tool provided by matplotlib?

You will want to ask on the matplotlib list:

  https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

Gmane