2

How would I go about implementing a band-pass filter in c#? I'm using a custom MediaStreamSource in Silverlight and am using additive synthesis to produce sound. My audio stream is a continuous stream of int16 shorts:

//over-simplified example:
short sample = oscillator.GetNextSample();
memoryStream.WriteByte((byte)(sample & 0xFF));
memoryStream.WriteByte((byte)(sample >> 8));

...where "sample" is a function of a sine calculation (or some other complex combination of waveforms) ranging from short.MinValue to short.MaxValue.

I have no idea where to start with a band-pass filter. How would I go about implementing it?

kindohm
  • 1,580
  • 18
  • 38

3 Answers3

1

Ah, this is what I'm looking for:

Low pass filter software?

I haven't tried it yet, but that is the raw calculation example I was hoping to find. It looks like I'll need to revise that code to work with Int16's instead of doubles, and it also looks like I have a lot of dirty work ahead of me for defining the particular constants/coefficients I'll need, but it should get me started in the right direction.

Community
  • 1
  • 1
kindohm
  • 1,580
  • 18
  • 38
0

See the answers to this question, in particular you might find Jacob's answer useful.

Community
  • 1
  • 1
Winston Smith
  • 21,585
  • 10
  • 60
  • 75
  • I'm not sure how well those responses will translate to my Silverlight app since they seem to be aimed toward managed DirectX or unmanaged libraries - both of which are not available in my context. I'm hoping to find some more "raw" computation examples. Those responses may help though - I'll take a look. – kindohm Nov 03 '09 at 17:12
0

puhh this is math , isn´t it ;-) So I guess its System.Math and read this free book

Ren Hoek
  • 315
  • 2
  • 14
  • Ren - could you try to put that file on a "better" free upload site like http://drop.io? the uploaded.to link is nagging me with wait times and the file never downloads. – kindohm Nov 03 '09 at 17:05
  • sorry it´s no upload from me, from this site http://freebooksource.com/blogroll/engineering-technology/signal-analysis-wavelets-filter-banks-time-frequency-transforms-and-applications/ – Ren Hoek Nov 04 '09 at 08:11