Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PortAudio libraries with ALSA support for Linux/Raspberry Pi #8

Open
CrystalMare opened this issue Sep 8, 2018 · 4 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed Linux/Raspberry Pi

Comments

@CrystalMare
Copy link

CrystalMare commented Sep 8, 2018

I've tried using the FFT example sketch to visualize the monitor output of my computer's sound card.
But I've noticed that there is a 2~ second delay between the audio output, and the visualization on the screen.

Any ideas what could be causing this?

I'm using Processing 3.3.7 and version 2.0.1 of processing-sound
Using GNU/Linux with ALSA&PulseAudio.

If you need any specific details, please tell me. I can't think of anything else to add.

public class AudioVisualizer extends PApplet {

    private FFT fft;
    private AudioIn in;
    private int bands = 16;
    private float[] spectrum = new float[bands];

    public static void main(String[] args) {
        PApplet.main(AudioVisualizer.class.getCanonicalName());
    }

    @Override
    public void settings() {
        size(512, 360);
    }

    @Override
    public void setup() {
        background(255);

        // Create an Input stream which is routed into the Amplitude analyzer
        fft = new FFT(this, bands);
        in = new AudioIn(this);
        // start the Audio Input
        in.start();
        in.play();

        // patch the AudioIn
        fft.input(in);
    }

    @Override
    public void draw() {
        background(255);
        fft.analyze(spectrum);

        for(int i = 0; i < bands; i++){
            // The result of the FFT is normalized
            // draw the line for frequency band i scaling it up by 5 to get more amplitude.
            line( i, height, i, height - spectrum[i]*height*5 );
        }
    }
}
@kevinstadler kevinstadler added the help wanted Extra attention is needed label Sep 12, 2018
@rvorias
Copy link

rvorias commented Aug 26, 2019

Also having this problem.
Processing 3.5.3
Elementary OS Juno (Ubuntu 18.04 LTS)
Checked code on windows and code is ok.

@JJ-Atkinson
Copy link

Was a solution found? Still see it.

Ubuntu 18.04 lts

@JJ-Atkinson
Copy link

I found a hack around this by using my headphone out connected directly to my mic in. Zero latency now.

@kevinstadler kevinstadler changed the title Latency issues with ALSA as input source Add PortAudio libraries with ALSA support for Linux/Raspberry Pi Sep 20, 2023
@kevinstadler kevinstadler added the enhancement New feature or request label Sep 20, 2023
@kevinstadler
Copy link
Collaborator

Adding the option of using PortAudio with ALSA support (in line with c64e56c) would probably greatly enhance latency/performance on Linux, see e.g. https://github.com/PortAudio/portaudio/wiki/Platforms_RaspberryPi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed Linux/Raspberry Pi
Projects
None yet
Development

No branches or pull requests

4 participants