# Tag Info

22

The physically "correct" way to do this is summing the samples. However when you add two arbitrary samples, the resulting value could be up to twice the maximum value. ... The naive solution here is to divide by N, where N is the number of channels being mixed. That's not the "naive" solution, its the only solution. That's what every analog and digital ...

21

You can use logarithms to get rid of the division. For $(x, y)$ in the first quadrant: $$z = \log_2(y)-\log_2(x)\\ \text{atan2}(y, x) = \text{atan}(y/x) = \text{atan}(2^z)$$ Figure 1. Plot of $\text{atan}(2^z)$ You would need to approximate $\text{atan}(2^z)$ in range $-30 < z < 30$ to get your required accuracy of 1E-9. You can take advantage of ...

20

The naive implementation of an $N$-point DFT is basically a multiplication by a $N \times N$ matrix. This results in a complexity of $\mathcal{O}(N^2)$. One of the most common Fast Fourier Transform (FFT) algorithm is the radix-2 Cooley-Tukey Decimation-in-Time FFT algorithm. This is a basic divide and conquer approach. First define the "twiddle factor" ...

19

It's very hard to point you to relevant techniques without knowing any context for your problem. The obvious answer would be to tell you to adjust the gain of each sample so that clipping rarely occurs. It is not that unrealistic to assume that musicians would play softer in an ensemble than when asked to play solo. The distortion introduced by A + B - AB ...

19

http://nbviewer.jupyter.org/gist/leftaroundabout/83df89a7d3bdc24373ea470fb50be629 DFT, size 16 FFT, size 16 The difference in complexity is pretty evident from that, isn't it? Here's how I understand FFT. First off, I would always think about Fourier transforms foremostly as transforms of continuous functions, i.e. a bijective mapping $\operatorname{FT} ... 18 I fear that all answers here are irrelevant to the question. What is called a vocoder in the music production world has little to do with the phase vocoder used in signal processing. To make matters worse the Songify app referenced by the original post is not an example of vocoder. Let us sort this out! 1. Phase vocoder The phase vocoder referenced by the ... 15 Here is a picture to add to Robert's good answer demonstrating the "re-use" of operations, in this case for an 8 point DFT. The "Twiddle Factors" are represented in the diagram using the notation$W_N^{nk}$which is equal to$e^{j2\pi \frac{nk}{N}}$Note the path shown and the equation underneath shows the result for the frequency bin X(1), as given by ... 14 I would be tempted to reply "none", or "both classification and clustering". Why "none"? Because HMMs are not in the same bag as support vector machines or k-means. Support vector machines or k-means are specifically designed to solve a problem (classification in the first case, clustering in the second), and are indeed just an optimization procedure to ... 13 This is a well-studied problem, dating back from the mid 90s (DARPA/NIST broadcast transcription challenges). Search for "speech/music segmentation" or "audio segmentation" and you'll find thousands of research papers. There are two broad approaches to solve this problem: Supervised classification Train a speech/music classifier, using a standard machine ... 13 if you want a cheap and dirty optimized power-series expansion (the coefficients for Taylor series converge slowly) for sqrt() and a bunch of other trancendentals, i have some code from long ago. i used to sell this code, but no one has paid me for it for nearly a decade. so i think i'll release it for public consumption. this particular file was for an ... 12 What you're describing is call deconvolution. It's a concept frequently used for distorted images and for equalization in communications. As such you should be able to find a number of resources for your specific application. In general, the original image may not be recoverable exactly (it often isn't). However, you can do a pretty good job depending on ... 11 The STFT transform pair can be characterized by 4 different parameters: FFT size (N) Step size (M) Analysis window (size N) Synthesis window (size N) The process is as follows: Grab N (fft size) samples from the current input location Apply analysis window Do the FFT Do whatever you want to do in the frequency domain Inverse FFT Apply synthesis window Add ... 11 The basic technique to place a mono source in stereo is called constant power panning. If you want to place a mono source at angle$\theta$you can just use$A_\mathrm{amp}$and$B_\mathrm{amp}$as amplitudes for your channels:$A_\mathrm{amp} = \frac{\sqrt{2}}{2} (\cos{\theta} + \sin{\theta})B_\mathrm{amp} = \frac{\sqrt{2}}{2} (\cos{\theta} - \sin{\...

10

You need to generate early reflections with a few taps of delays (= convolution with the sum of a handful of diracs) ; and the "tail" with what is usually implemented with a network of all-pass (AP) and comb filters. The first part is trivial to implement but difficult to get to sound right. It might help to look at the positioning of peaks at the head of ...

10

Thanks to the plot in Olli Niemitalo's answer I got convinced that the formula given in the book has a sign error. The non-linearity used for fuzz or distortion is always some type of smoothed clipping function, which compresses the input signal. So small input amplitudes experience little change whereas high input amplitudes are (more or less) softly ...

9

This paper discusses all of the modern exact distance transforms: "2D Euclidean distance transforms: a comparative survey", ACM Computing Surveys, Vol 40, Issue 1, Feb 2008 http://www.lems.brown.edu/~rfabbri/stuff/fabbri-EDT-survey-ACMCSurvFeb2008.pdf The paper cites the technique from Meijster, et. al. as the fastest general purpose, exact transform. This ...

9

the CPU/DSP has hardware floating point support for both single and double precision. It really depends on what kind of support you are talking about. On x86, when using the x87 style floating point instructions, you get the full 80-bit internal precision and the same processing time - whether you are working with single or double precision. But when using ...

9

IEEE float singles only provide about 24 bits of mantissa. But many DSP/filtering algorithms (IIR biquads with poles/zeros near the unit circle, etc.) require far more than 24 bits of mantissa for intermediate computational products (accumulators, etc.), just to get final results accurate to near 16 or 24 bits. For these types of algorithms, 32, 40 and 48-...

9

the general polynomial form is: \begin{align} f(u) &= \sum\limits_{n=0}^{N} \ a_n \ u^n \\ \\ &= a_{\small{0}} + \Bigg(a_{\small{1}} + \bigg(a_{\small{2}} + \Big(a_{\small{3}} + \,... \big(a_{\small{N-2}} + (a_{\small{N-1}} + a_{\small{N}} \,u \,)u \, \big)u \ ...\Big)u \, \bigg)u \, \Bigg)u\\ \end{align} the latter form is using Horner's ...

9

PROLOGUE My answer to this question is in two parts since it is so long and there is a natural cleavage. This answer can be seen as the main body and the other answer as appendices. Consider it a rough draft for a future blog article. Answer 1 * Prologue (you are here) * Latest Results * Source code listing * Mathematical justification for ...

9

You mention in a comment that your target platform is a custom IC. That makes the optimization very different from trying to optimize for an already existing CPU. On a custom IC (and to a lesser extent, on an FPGA), we can take full advantage of the simplicity of bitwise operations. In addition, to reduce the area it is not only important to reduce the ...

8

In this particular case, this would be quite difficult. The filter is a low pass with 30 dB of attenuation (mostly) but it has also two zeros on the unit circle. You can design an approximation for the inverse filter but it won't be perfect The filter is linear phase, so the inverse filter is also linear phase but non-causal. In practice this means you'll ...

8

Making a good sounding reverb is NOT easy. Feedback delay networks are definitely the way to go. The original Schroeder algorithms with all passes and comb filters suffers from "spectral thinning" which makes it metallic sounding. You need to dial in frequency dependent attenuation on the different delay lines that's representative of the reverb time (as a ...

8

essentially, in computing the naive DFT directly from the summation: $$X[k] = \sum\limits_{n=0}^{N-1} x[n] \, e^{j 2 \pi \frac{nk}{N}}$$ there are $N$ table lookups for the twiddle factor $e^{j 2 \pi \frac{nk}{N}}$, $N$ complex multiplications, and $N-1$ additions. and that's just for one value of $X[k]$ and one instance of $k$. then the naive DFT ...

8

Question 1 If you apply it over the entire length of the array, the length of the FFT would be the length of the array. But, the FFT is more efficient if the length is a power of two, so it is common to pad 0's onto the end of the signal until its length is a power of 2. Overly simple example... x = [3.4, 2.56, 1.3] x has a length of 3, the next power of ...

8

1. Logarithms and exponents to avoid multiplication To completely avoid multiplication, you could use $\log$ and $\exp$ tables and calculate: $$I^2 + Q^2 = \exp\!\big(2\log(I)\big) + \exp\!\big(2\log(Q)\big).\tag{1}$$ Because $\log(0) = -\infty,$ you'd need to check for and calculate such special cases separately. If for some reason accessing the $\exp$ ...

8

Given two complex numbers $z_1=a_1+jb_1$ and $z_2=a_2+jb_2$ you want to check the validity of $$a_1^2+b_1^2>a_2^2+b_2^2\tag{1}$$ This is equivalent to $$(a_1+a_2)(a_1-a_2)+(b_1+b_2)(b_1-b_2)>0\tag{2}$$ I've also seen this inequality in Cedron Dawg's answer but I'm not sure how it is used in his code. Note that the validity of $(2)$ can be checked ...

7

Consider the frequency response of the filter. If the source image contains data with spectrum exactly at the frequency of a notch in the filter, this data will be lost after convolution. There is no operator that can reasonably recover non-zero data from an image filtered into a bunch of zeros. There can also be arithmetic quantization issues, thus ...

7

As said by Jason, this might simply be that you are not implementing your oscillator correctly - for example by multiplying the frequency by time instead of integrating it. Note also - and this is unrelated to your topic but really worth observing - that your formula for frequency modulation implements a behavior very different to that of most synthesizers, ...

7

A few notes regarding your approach and detailed questions: First, it is very common in audio analysis to split the signal to be analyzed into short overlapping windows, because audio signals are not stationary (their characteristics change over time), so they need to be processed on short segments over which they can be considered stationary (many analyses ...

Only top voted, non community-wiki answers of a minimum length are eligible