Mercurial > hg > beaglert
comparison examples/04-Audio/tremolo/render.cpp @ 538:58652b93ef7e prerelease
Converted some spaces to tabs
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 24 Jun 2016 01:40:25 +0100 |
parents | e2364e1711c2 |
children | a11814e864a8 |
comparison
equal
deleted
inserted
replaced
536:b97fe1dc4278 | 538:58652b93ef7e |
---|---|
39 | 39 |
40 void render(BelaContext *context, void *userData) | 40 void render(BelaContext *context, void *userData) |
41 { | 41 { |
42 // Nested for loops for audio channels | 42 // Nested for loops for audio channels |
43 for(unsigned int n = 0; n < context->audioFrames; n++) { | 43 for(unsigned int n = 0; n < context->audioFrames; n++) { |
44 | 44 |
45 // Generate a sinewave with frequency set by gFrequency | 45 // Generate a sinewave with frequency set by gFrequency |
46 // and amplitude from -0.5 to 0.5 | 46 // and amplitude from -0.5 to 0.5 |
47 float lfo = sinf(gPhase) * 0.5; | 47 float lfo = sinf(gPhase) * 0.5; |
48 // Keep track and wrap the phase of the sinewave | 48 // Keep track and wrap the phase of the sinewave |
49 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; | 49 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; |
50 if(gPhase > 2.0 * M_PI) | 50 if(gPhase > 2.0 * M_PI) |
51 gPhase -= 2.0 * M_PI; | 51 gPhase -= 2.0 * M_PI; |
52 | 52 |
53 for(unsigned int channel = 0; channel < context->audioChannels; channel++) { | 53 for(unsigned int channel = 0; channel < context->audioChannels; channel++) { |
54 // Read the audio input and half the amplitude | 54 // Read the audio input and half the amplitude |
55 float input = audioRead(context, n, channel) * 0.5; | 55 float input = audioRead(context, n, channel) * 0.5; |
56 // Write to audio output the audio input multiplied by the sinewave | 56 // Write to audio output the audio input multiplied by the sinewave |
57 audioWrite(context, n, channel, (input*lfo)); | 57 audioWrite(context, n, channel, (input*lfo)); |
58 | |
59 } | 58 } |
60 } | 59 } |
61 | 60 |
62 // Nested for loops for analog channels | 61 // Nested for loops for analog channels |
63 for(unsigned int n = 0; n < context->analogFrames; n++) { | 62 for(unsigned int n = 0; n < context->analogFrames; n++) { |
64 for(unsigned int ch = 0; ch < context->analogChannels; ch++) { | 63 for(unsigned int ch = 0; ch < context->analogChannels; ch++) { |
65 // Read analog channel 0 and map the range from 0-1 to 0.25-20 | 64 // Read analog channel 0 and map the range from 0-1 to 0.25-20 |
66 // use this to set the value of gFrequency | 65 // use this to set the value of gFrequency |
67 gFrequency = map(analogRead(context, n, 0), 0.0, 1.0, 0.25, 20.0); | 66 gFrequency = map(analogRead(context, n, 0), 0.0, 1.0, 0.25, 20.0); |
68 | |
69 } | 67 } |
70 } | 68 } |
71 | 69 |
72 } | 70 } |
73 | 71 |