signal-processing

Why am I getting a blank image as my output?

牧云@^-^@ 提交于 2019-12-23 10:00:04
问题 Here's some code I wrote to display the magnitude spectrum of an image: orig_imdata = imread('Original_Image.png'); spec_orig = fft2(double(orig_imdata)); spec_orig2 = abs(spec_orig); spec_img = fftshift(spec_orig2); imshow(spec_img); When I comment out the use of abs and just fftshift the image, I get an image, albeit with the phase and the magnitude. If I apply the abs function right after using fftshift , I get a blank result from imshow . I need an image of the magnitude of the spectral

Implement realtime signal processing in Python - how to capture audio continuously?

旧街凉风 提交于 2019-12-23 07:48:21
问题 I'm planning to implement a "DSP-like" signal processor in Python. It should capture small fragments of audio via ALSA, process them, then play them back via ALSA. To get things started, I wrote the following (very simple) code. import alsaaudio inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL) inp.setchannels(1) inp.setrate(96000) inp.setformat(alsaaudio.PCM_FORMAT_U32_LE) inp.setperiodsize(1920) outp = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL) outp

How to implement a high-pass filter for an audio signal?

我的梦境 提交于 2019-12-23 05:47:12
问题 I am trying to do a music identification application like shazam. This is an android app. First i have captured an audio signal through the MIC. Next I have implemented the hanning window function and FFT to the audio signal as shown as following code : private class RecordAudio extends AsyncTask<Void, double[], Void> { @Override protected Void doInBackground(Void... params) { started = true; try { DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(

How to write lowpass filter for sampled signal in Python?

只谈情不闲聊 提交于 2019-12-23 05:26:18
问题 Sorry for question that may be trivial, but I am new in signal processing, and I didn't find python code with good explanation. So I will be glad to get explanation for dummy :) I have some signal that sampled each 1 nsec (1e-9 sec) and have, let say, 1e4 points. I need to filter high frequencies from this signal. Let say I need to filter frequencies higher than 10MHz. I want that for frequencies lower than cutoff frequency signal will be passed unchanged. It means gain of the filter will be

convert WAVE file into vectors in Android

杀马特。学长 韩版系。学妹 提交于 2019-12-23 05:15:46
问题 Im searching for a way to convert Wave files into a list of numbers to cross-correlate the resulting vectors (like the numbers you get when you read a wave file on MATLAB) 0.6653 -0.8445 0.9589 -0.9999 0.9643 -0.8547 0.6797 -0.4525 0.1907 0.0858 -0.3557 0.5983 -0.7951 0.9309 -0.9953 0.9835 -0.8962 0.7402 -0.5275 0.2742 is there a way to do that in Android or even C/C++? i really dont know how to start. 回答1: WAVE file format is fairly simple, especially if you're interested in linear PCM

Copy void* content into SigLib struct SLData_t*

不问归期 提交于 2019-12-23 04:54:14
问题 I am doing an Windows application using C++. I have the next dude. I have this function where I receive a void * with data audio capture: void Pre_proc_mono::PreProcess(void *data, int lenbytes) { SLData_t *signal1; SLData_t *signal2; SLData_t *result; signal1 = (SLData_t*)data; signal2 = new SLData_t[lenbytes]; result = new SLData_t[2 * lenbytes - 1]; for (int i = 0; i < lenbytes; i++){ signal2[i] = signal1[i]; } } The loop always fail around 11000, why? What am I doing wrong ? The idea is

Time optimization of function for signal processing

烈酒焚心 提交于 2019-12-23 04:29:36
问题 I have a program doing a LOT of iteration (thousands to millions to hundreds of millions). It's starting to take quite a lot of time (few minutes, to a few days), and despite all my effort to optimize it, I'm still a bit stuck. Profile: using cProfile via console call ncalls tottime percall cumtime percall filename:lineno(function) 500/1 0.018 0.000 119.860 119.860 {built-in method builtins.exec} 1 0.006 0.006 119.860 119.860 Simulations_profiling.py:6(<module>) 6/3 0.802 0.134 108.302 36.101

Count Steps using accelometer in android [duplicate]

北慕城南 提交于 2019-12-23 04:19:07
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to Count the Number of Steps Using the Accelerometer Are there any well known algorithms to count steps based on the accelerometer? Hi i have developed android application. In one module I have to create a pedometer. Now at this stage I have to count the steps user walked by using accelormeter. I have search on internet and found different methods but none of that working. I have tried this Does anyone have

Streaming Data to Sound Card Using C on Windows [closed]

懵懂的女人 提交于 2019-12-23 01:12:58
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . As part of a university project I have to do some signal processing and would like to output the results using the PC sound card. The software has to be written in C and needs to work with Windows (preferably 7 and XP). I have found code examples for outputting .wav and similar files, but I am interested in

From Amplitude or FFT to dB

假如想象 提交于 2019-12-23 00:26:49
问题 I've a Python code which performs FFT on a wav file and plot the amplitude vs time / amplitude vs freq graphs. I want to calculate dB from these graphs (they are long arrays). I do not want to calculate exact dBA, I just want to see a linear relationship after my calculations. I've dB meter, I will compare it. Here is my code: #!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import scipy.io.wavfile as wavfile import scipy import scipy.fftpack import numpy as