?
=?ISO-8859-1?Q?Asbj=F8rn?= Ulsberg
I'm writing a little C# / DirectSound piano which uses
SecondaryBuffer to play .wav-files. The SecondaryBuffer has a
Frequenzy property which I set to modulate the .wav file into
playing the right note.
The algorithm for a given frequenzy is «x * 2 ^ (y / 12)», where
'x' is the start frequenzy (I use 440 which is A) and 'y' is the
number of half notes from x the given note is. If I am going to
get the frequenzy of a C, the formula would look like this: «440
* 2 ^ (3 / 12)», and the result should be 523,251130601[...]Hz.
But I can't figure out a way to get this algorithm to work. If I
only use integers in the algorithm, it works, but I need a
_much_ higher precision level than int. I would like to use
decimal, but neither that, nor float or double works. I've tried
everything it seems, but nothing works.
How can I apply the ^ operator to other types than integer?
SecondaryBuffer to play .wav-files. The SecondaryBuffer has a
Frequenzy property which I set to modulate the .wav file into
playing the right note.
The algorithm for a given frequenzy is «x * 2 ^ (y / 12)», where
'x' is the start frequenzy (I use 440 which is A) and 'y' is the
number of half notes from x the given note is. If I am going to
get the frequenzy of a C, the formula would look like this: «440
* 2 ^ (3 / 12)», and the result should be 523,251130601[...]Hz.
But I can't figure out a way to get this algorithm to work. If I
only use integers in the algorithm, it works, but I need a
_much_ higher precision level than int. I would like to use
decimal, but neither that, nor float or double works. I've tried
everything it seems, but nothing works.
How can I apply the ^ operator to other types than integer?