Giter VIP home page Giter VIP logo

realtime_pyaudio_fft's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

realtime_pyaudio_fft's Issues

Close button is not working and need to insert new function

Hello, I noticed when I push the close button, it doesn't work and I tried to track it but I failed.

I'm a beginner so the code level is kind of advanced and I want to make a function contains a loop for making some classes for the range of the frequency like a classifier. So is there any hint for making this? Or where could I use it?

Thank you

This and BirdNET-Pi

Howdy!!! I just wanted to say thank for this repo and the time you spent putting it together. I'll be looking at bringing this into BirdNET-Pi for realtime spectrograms and the development I'm doing around bats :)

My very best regards,
Patrick

Can't read system audio

I can't read the system audio for the visualizer. How did you do it in your teaser? I would like my program to act like this. Thanks!

error installing on mint 19.3

i use virtualenv:
virtualenv -p /usr/bin/python3.6 venv-3.6
source venv-3.6/bin/activate
pip3 install -r requirements.txt

i changed the requirement file to include versions (i suggest to update the file with versions)
numpy==1.18.4
matplotlib==3.2.1
scipy==1.4.1
pygame==1.9.6
PyAudio==0.2.11

but pyAudio give me error
Collecting PyAudio==0.2.11
src/_portaudiomodule.c:29:10: fatal error: portaudio.h: File o directory non esistente
#include "portaudio.h"
^~~~~~~~~~~~~
compilation terminated.

solved installing portaudio via apt:

sudo apt install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0

Logarithmic Scaling for X Axis

Is it possible to change the x axis to logarithmic? So that you can see Basslines, Vocals more clearly and the hihats and cymbals dont take up 3/4 of the screen.

Use this script with a wav file

Hello!

I would like to use this visualizer but with a WAV file as an input instead of a microphone stream. It should be pretty easy to edit the code to use a Wave_read object (from the wave package) instead of the current input, but I can't manage to do it. Perhaps someone here can help me?

Thanks for your wonderful job btw, this is a really good ressource :)

low fps on raspberry cm4

I test it on raspberry cm4 lite
changed the window to 320x240
but the fps is just 10
then I run it on laptop fps is about 50
how can I improve fps on raspberry?
3q

Pip install wrong command

There is a typo in the readme file regarding the installation. The correct command should be:

pip install -r requirements.txt

Add functionality to read wav file

Unfortunately doesn't work with:

wf = wave.open("my.wav", "rb")

self.stream = p.open(
    format=p.get_format_from_width(wf.getsampwidth()),
    channels=wf.getnchannels(),
    rate=wf.getframerate(),
    output=True,
    stream_callback=self.callback,
)

My desired device doesn't work with default settings?

Hello, I'm running this in Windows 10 with python 3.11.0
I first had issues with the requierements file but removing the required version numbers fixed it (amazing).
The issue is that I want to see my speakers output that are the number 5 in the list, so I use the --device 5 but then this message appears
Input sound settings for device 5 and samplerate None Hz not supported, using defaults...
And then the algorithm defaults to my microphone and works just fine.

I tried changing the sample rate to match the actual device rate (check it in the windows sound config menu) but it says the same "not supported" so I was wondering if theres anything else I'm missing I should change.

Thank you

Issue on MAC OSX

site-packages/numpy/core/numeric.py", line 223, in ones
a = empty(shape, dtype, order)
TypeError: 'float' object cannot be interpreted as an index

caused by line 130 of "src/stream_reader_sounddevice.py".

solved by adding a hard cast to int.

self.data_windows_to_buffer = int(data_windows_to_buffer)

sounddevice.PortAudioError: Error querying device -1

Following the README.md operation will run out of this error:
Traceback (most recent call last):
File "/home/junyiwu/Realtime_PyAudio_FFT/Realtime_PyAudio_FFT/run_FFT_analyzer.py", line 4, in
ear = Stream_Analyzer(
File "/home/junyiwu/Realtime_PyAudio_FFT/Realtime_PyAudio_FFT/src/stream_analyzer.py", line 51, in init
self.stream_reader = Stream_Reader(
File "/home/junyiwu/Realtime_PyAudio_FFT/Realtime_PyAudio_FFT/src/stream_reader_sounddevice.py", line 52, in init
with sd.InputStream(samplerate=self.rate,
File "/home/junyiwu/.local/lib/python3.10/site-packages/sounddevice.py", line 1381, in init
_StreamBase.init(self, kind='input', wrap_callback='array',
File "/home/junyiwu/.local/lib/python3.10/site-packages/sounddevice.py", line 777, in init
_get_stream_parameters(kind, device, channels, dtype, latency,
File "/home/junyiwu/.local/lib/python3.10/site-packages/sounddevice.py", line 2571, in _get_stream_parameters
info = query_devices(device)
File "/home/junyiwu/.local/lib/python3.10/site-packages/sounddevice.py", line 569, in query_devices
raise PortAudioError('Error querying device {0}'.format(device))

want to know how to improve
Ubuntu 22.04.1

export DISPLAY=:0 run on Pi 4 8GB RAM

I run on Pi 4 8GB Ram (64 bit)
Linux 6.1.21-v8+ aarch64 GNU/Linux
LCD 5 inche

Using command: export DISPLAY=:0 && python3 run_FFT_analyzer.py
Show it OK, spectrum not play.

I check sound of pippopeppy is OK, Pygame work with pippopeppy is OK.

My log:
##################################################################################################

Defaulted to using first working mic, Running on:

MIC 1:
defaultHighInputLatency: 0.034829931972789115
defaultHighOutputLatency: 0.034829931972789115
defaultLowInputLatency: 0.008707482993197279
defaultLowOutputLatency: 0.008707482993197279
defaultSampleRate: 44100.0
hostApi: 0
index: 1
maxInputChannels: 32
maxOutputChannels: 32
name: pippopeppy
structVersion: 2

##################################################################################################
Recording from pippopeppy at 41000 Hz
Using (non-overlapping) data-windows of 42 samples (updating at 976.19fps)

Applying temporal smoothing to the FFT features...
Smoothing buffer contains 3 FFT windows (sigma: 1.000) --> min_contribution: 13.534%
Filter weights:
03: 0.233
02: 1.045
01: 1.722
Using FFT_window_size length of 2460 for FFT ---> window_size = 60ms
##################################################################################################

-- Starting live audio stream...

Starting spectrum visualizer...

Error message on startup

Super cool program. Congrats.

I'm going to try this with Ubuntu 16.04 (Python 2.7.12) so will have to do a little tweaking.

Tweak #1:

Error message on startup:

~/python/audio$ python run_FFT_analyzer.py

Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 2, in <module>
    from src.stream_analyzer import Stream_Analyzer
ImportError: No module named src.stream_analyzer

To fix this error I used:

~/python/audio$ cd src

~/python/audio/src$ echo "" > __init__.py

TWEAK #2:

I'll be revising this comment from time to time as I run into new issues. For example I will need to add program header stub for UTF-8 encoding due to this new error that popped up after fixing above error:

$ python run_FFT_analyzer.py
Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 58, in <module>
    run_FFT_analyzer()
  File "run_FFT_analyzer.py", line 45, in run_FFT_analyzer
    window_ratio = window_ratio  # Float ratio of the visualizer window. e.g. 24/9
  File "/home/rick/python/audio/src/stream_analyzer.py", line 50, in __init__
    from src.stream_reader_sounddevice import Stream_Reader
  File "/home/rick/python/audio/src/stream_reader_sounddevice.py", line 131
SyntaxError: Non-ASCII character '\xf0' in file /home/rick/python/audio/src/stream_reader_sounddevice.py on line 131, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

This is solved by inserting one line:

# -*- coding: utf-8 -*-

TWEAK #3:

The next error that appears:

$ python run_FFT_analyzer.py
Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 58, in <module>
    run_FFT_analyzer()
  File "run_FFT_analyzer.py", line 45, in run_FFT_analyzer
    window_ratio = window_ratio  # Float ratio of the visualizer window. e.g. 24/9
  File "/home/rick/python/audio/src/stream_analyzer.py", line 50, in __init__
    from src.stream_reader_sounddevice import Stream_Reader
  File "/home/rick/python/audio/src/stream_reader_sounddevice.py", line 5, in <module>
    import sounddevice as sd
ImportError: No module named sounddevice

This is more complicated a fix as described here:

Because the solutions provided use pip or pip3 in Ubuntu which won't work because I only sudo apt install the real solution will be more complicated.

Changing inputs doesn't work (Not supported)

Device 14 are my headphones. I don't want to use the visualizer for my mic. This is what it gives me:
Input sound settings for device 14 and samplerate 44100 Hz not supported, using defaults...
Defaulted to using first working mic, Running on mic 1

Is there any way to make a unsupported device supported?
Or is there anything I'm doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.