5
$\begingroup$

Okay, so hopefully this isn't too hard or off-topic. Let's say I have a very simple lowpass filter (something that smooths out a signal), and the filter object has a position variable and a cutoff variable (between 0 and 1). In every step, a value is put into the following bit of pseudocode as "input": position = position*(1-c)+input*c, or more mathematically, f(n) = f(n-1)*(1-c)+x[n]*c. The output is the value of "position." Basically, it moves a percentage of the distance between the current position and then input value, stores this value internally, and returns it as output. It's intentionally simplistic, since the project I'm using this for is going to have way too many of these in sequence processing audio in real time.

Given the filter design, how do I construct a function that takes input frequency (where 1 means a sine wave with a wavelength of 2 samples, and .5 means a sine wave with wavelength 4 samples, and 0 is a flat line), and cutoff value (between 1 and 0, as shown above) and outputs the amplitude of the resulting sine wave? Sine wave comes in, sine wave comes out, I just want to be able to figure out how much quieter it is at any input and cutoff frequency combination.

  • 0
    I have voted to close, as this is clearly not related to mathematics.2010-07-21
  • 2
    I think, with a little effort, the question can be written in purely mathematical language.2010-07-21
  • 0
    Moreover, my thinking in asking it was that any sort of function or proof to the problem is inherently mathematical. Sure, it's using math to actually *do useful things,* but I always kinda thought that was the point of math.2010-07-21
  • 0
    @Campadrenalin: Could you edit your question to add a little more detail? The current wording makes it hard to understand exactly what you're after.2010-07-24
  • 0
    I get the feeling I could answer the question if a version was given that removed the semantics, and was stated more like an equation.2010-07-25
  • 0
    I don't think your pseudocode does what you want it to do. Are you sure you don't mean f[n] = f[n-1]*(1-c) + x[n]*c?2010-07-29
  • 0
    Yes, I'm going to fix that. I just find it so much easier to think in programming languages than math syntax, and it makes it hard to switch back without spilling stupid all over the place :/ But nice catch, and thanks.2010-08-01

2 Answers 2