Re: DirectSound



<snip>
for a simple sine wave out, you can use the basic trig sin/cos math
to plot the PCM bits.
<snip>

A neat trick for generating sampled single frequency PCM signals is
to :

1 Generate an array of samples for a 1Hz wave at the PCM sampling rate
you intend to use.

2 Generate the consecutive values you need for frequency Fs by
sampling the above array every Fs'th element. Obviously you have to
wrap around when you've got past the end of the array by modding with
the array size

ithPCMValue := My1HzArray[(Fs * i) mod (High(My1HzArray) + 1)];

This should be quicker than calculating the sin of every sample. For a
cos value, increment the array access argument by (SamplingRate div 4)
or generate another 1Hz array for cos values from the 1Hz sin array.

Alan Lloyd



.



Relevant Pages

  • Re: DFT Function
    ... Evidently you were expecting a peak around 5.5. ... you're sampling 5 and a half ... all values of the output array are very close to 1.0. ... David Bernier ...
    (sci.math)
  • Re: DFT Function
    ... Here is the code that fills the input array: ... Evidently you were expecting a peak around 5.5. ... you're sampling 5 and a half ... "Understanding Godel isn't about following his formal proof. ...
    (sci.math)
  • Re: HANDLING LARGE MATRICES
    ... matrixis slow because thematrixis stored by column. ... using that index i split that array into two different arrays. ... i could achieve considerable speed up by first splitting the matrix in ... two parts and sampling from both parts. ...
    (comp.soft-sys.matlab)
  • sampling without replacement
    ... Greetings -- I am doing a sampling without replacement, ... random elements from an array. ... The picked element is then removed ... Using an array is natural here as it represents "without replacement" ...
    (comp.lang.python)