ios - generating the square wave with pulses -
I am trying to modify the method of creating square wave
Can generate different pulse width with 0.3ms each delay in one per period I have seen that sampleBuffer is responsible for generating pulse signals, but I'm not sure how to do the pulse function for such a specific pattern Can you please make me tell that pulse What is the Library function on AudioTrack.h?
Below is my code
zero generated square (SInt16 * sampleBuffer, int numframes, float sample rate, float frequency, float amp) {if (amp & gt; ; 1) amp = 1; If (amp & lt; 0) amp = 0; Amp = amp * SHRT_MAX; Float samplesPerCycle = sampleRate / frequency; For (Int i = 0; I 0.5) {Sample Buffer [I] = amp; } And {sample buffer [i] = -1 * amp; } SquareIndex = squareIndex + 1; If (squareindx> = cycler at the sample) squareindex- = samayperecyclical; }}
Here's my solution for the same problem
My issues I make pulse with 1 mms width, which I am modifying with the fill value till +/- 0.5ms. According to the filling, I create a square wave with a width of 0.5-1.5 MB.
int squareIndex = 0; Zero-Generated Squeeze (SInt16 * Sampler buffer, intro neframe, float sample rate, float flawl, float amp) {// fill in the value = pulse width value in // // fillValue = [-20, 20]; If (amp & gt; 1) amp = 1; If (amp & lt; 0) amp = 0; If (fill value & gt; 20) fillValue = 20; If (Fill well and lieutenant; -20) fill value = -20; Amp = amp * SHRT_MAX; Float samplesPerCycle = sampleRate / 50; // sample / cycle = 882 // 1ms = 41 frames - & gt; 0.5 ms = 20 (.5) frame // 0.3 ms = 12 (.3) frame # Purgama mark in your case - PWM for (int i = 0; i & lt; nffms; i ++) {// if ( FMODF (Square Indexes, SamplePearcycle) / SamplesCycle and LT; 0.05) {If (SquareIndex <41 + Fill Value) {sampleBuffer [i] = 1 * SHRT_MAX; } And {sample buffer [i] = 0; } SquareIndex = squareIndex + 1; If (squareindx> = cycler at the sample) squareindex- = samayperecyclical; }}
Comments
Post a Comment