Questions tagged [c]

C is a high level (i.e. not assembler) programming language often used to program DSPs and other embedded microprocessors as well as being used for systems programming. Features of the language make it especially suitable for programming hardware and writing device drivers.

C is a high level (i.e. not assembler) programming language often used to program DSPs and other embedded microprocessors as well as being used for systems programming. Features of the language make it especially suitable for programming hardware and writing device drivers.

130 questions
17
votes
2 answers

Add odd/even harmonics to signal?

How do I add odd or even harmonics to a floating point signal? Do I have to use tanh or sin? What I'm trying to do is achieve some very simple distortion effects, but I'm having a hard time finding exact references. What I'd like is something…
Carlos Barbosa
  • 273
  • 1
  • 2
  • 5
14
votes
6 answers

What Approximation Techniques Exist for Computing the Square Root?

I have very limited resources as I'm working with a microcontroller. Is there a taylor-series expansion, common lookup table, or recursive approach? I'd prefer to do something without using math.h's…
tarabyte
  • 395
  • 2
  • 4
  • 10
13
votes
2 answers

Real-valued ringing when zero-padding odd-length FFT

So I'm trying to write a frequency-domain interpolator that zero-pads the frequency response of a signal and inverse transforms. There's two cases I have to deal with: Even-length response - have to split the $F_s/2$ bin because it's ambiguous. …
gct
  • 288
  • 1
  • 9
13
votes
4 answers

Recommendation for book - Writing DSP code in C

I am looking for some good book, that simply show how you actually write a code in C, to do all the main DSP methods . FFT. Low-pass and high-pass filters. Auto-correlation. Noise processing. And all the basics of DSP, from theory into a real code…
Curnelious
  • 1
  • 3
  • 10
11
votes
3 answers

Digital Distortion effect algorithm

I read the DAFX book by Udo Zölzer about the distortion effect at pages 124-125 and it says that suitable simulation of the distortion is given by the function: $$f(x)=\frac{x}{|x|}\left(1-e^{x^2/|x|}\right)$$ Can someone explain this formula and…
Elior
  • 241
  • 1
  • 2
  • 11
10
votes
6 answers

How can I work on DSP using C/C++?

I have been working on MATLAB for signal processing for a while. Many companies from DSP for a communication background has asked me whether I know C/C++ very well. I am confused as to why the companies are using C/C++ for signal processing. Why not…
Sukshith Shetty
  • 101
  • 1
  • 4
10
votes
8 answers

How can I generate a sine wave with time varying frequency that is continuous, in C?

How can I generate a sine wave with time varying frequency that is continuous? How can I resolve the following problem? I want a continuous graph. I'm generating this simply like this: for(int i = 0; i < pcm_buffer_size - 1; i += 2) { float…
deltafft
  • 105
  • 1
  • 1
  • 6
9
votes
3 answers

How does a low-pass filter programmatically work?

I have been working on a simple low pass filter for < 100 Hz metering in my application. But so far, I am struggling with the theory behind it all. It's cool that I got it working, but I'd really enjoy it if I knew how/why it is working. I found the…
Niek van der Steen
  • 235
  • 1
  • 2
  • 8
8
votes
7 answers

How to implement a moving average in C without a buffer?

Is it possible to implement a moving average in C without the need for a window of samples? I've found that I can optimize a bit, by choosing a window size that's a power of two to allow for bit-shifting instead of dividing, but not needing a buffer…
tarabyte
  • 395
  • 2
  • 4
  • 10
8
votes
4 answers

Optimized Ansi C libraries for DSP

I am new to DSP? Where is a good resource for open source DSP algorithms? MATLAB is great at making protos but once we move to C coding, it takes time and we end up making too many mistakes. I would guess there must be good repositories of C codes…
Ktuncer
  • 806
  • 2
  • 10
  • 18
4
votes
2 answers

Implementing a Butterworth Filter Manually in C/C++ via Second Order Sections

Short background: I want to implement a lowpass butterworth filter in C/C++. The end goal is to use this in a low-latency Python program, for which of course scipy.signal exists, but I want to be able to change the cutoff frequency (smoothly) at…
4
votes
1 answer

Wrong result when realizing fixed-point biquad IIR filter

I'm implementing a fixed-point direct form I biquad filter with Q1.15 precision. I use fraction saving to improve quantization error. However, my function gives me the different results compared by MATLAB's filter. I didn't find anything wrong,…
DSP novice
  • 149
  • 7
4
votes
2 answers

How to set parameters of the PI controller inside the PLL?

I am going to implement in C++ software the synchronous frame phase locked loop (SFPLL) for estimation of angle and frequency of the three phase grid 220V/50Hz. For the internal PI controller setting I have decided to use the design by emulation…
Steve
  • 231
  • 6
4
votes
1 answer

Smoothed Square Wave

new here and probably pretty unexperienced compared to the rest of you. This should be simple enough but just wanted some clarification. I'm trying to model an analog square wave oscillator with C. With the oscillator I'm trying to mimic, the square…
yun
  • 189
  • 1
  • 11
4
votes
2 answers

Forward and Backward Filtering (MATLAB's `filtfilt()`)

I have an input sequence $x(n)$ and impulse sequence \begin{equation} h(n) = \begin{cases} 0 & \quad \text{when } n = 0 \\ .239052 & \quad \text{when } n = 1 \\1.3357\exp(-0.650286n) & \quad \text{when } n > 1\\ \end{cases} \end{equation} I did a…
rkhds
  • 57
  • 3
1
2 3
8 9