Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use DesktopAudio version 1.0
- signal Accum {}
- switch ResetOuter { }
- signal OuterCounter { reset: ResetOuter}
- loop Loop {
- ports: [
- ]
- blocks: [
- signal Counter {}
- switch CounterReset {}
- ]
- streams: [
- Accum + 2 >> Accum;
- Counter + 1 >> Counter;
- [Counter, 10] >> Equal() >> CounterReset;
- ]
- terminateWhen: CounterReset
- }
- [OuterCounter, 20] >> Equal() >> ResetOuter >> Loop();
- OuterCounter + 1 >> OuterCounter;
- Accum >> AudioOut[1];
- ----------------------------------
- #include "RtAudio.h"
- #include <iostream>
- #include <cstdlib>
- #include <cstring>
- //[[Includes]]
- //[[/Includes]]
- //[[Declarations]]
- class Equal {
- public:
- float Input[2];
- float EqualBlock;
- float Output;
- Equal() {
- Input[0] = 0;
- Input[1] = 0;
- EqualBlock = 0.0;
- Output = 0;
- }
- void process__OutputDomain(float Input[2], float &Output) {
- // Starting stream 00 -------------------------
- Output = Input[0] == Input[1];
- // Stream End 00
- }
- };
- float Accum;
- void Loop_process_AudioDomain(float &Accum) {
- float Counter;
- float _Equal_048_out;
- Equal Equal_048;
- bool CounterReset;
- Counter = 0;
- CounterReset = false;
- while (!CounterReset) {
- // Starting stream 00 -------------------------
- Accum = (Accum + 2);
- // Stream End 00
- // Starting stream 01 -------------------------
- Counter = (Counter + 1);
- // Stream End 01
- // Starting stream 02 -------------------------
- float _bundle_connector_56[2];
- _bundle_connector_56[0] = Counter;
- _bundle_connector_56[1] = 10;
- Equal_048.process__OutputDomain(_bundle_connector_56, _Equal_048_out);
- CounterReset = _Equal_048_out;
- // Stream End 02
- }
- }
- float OuterCounter;
- void _OuterCounterReset_process_AudioDomain(float &OuterCounter) {
- // Starting stream 00 -------------------------
- // Stream End 00
- // Starting stream 00 -------------------------
- OuterCounter = 0;
- // Stream End 00
- }
- float _Equal_014_out;
- Equal Equal_014;
- bool ResetOuter;
- float AudioOut[2];
- #include <iostream>
- #include <iomanip>
- #define NUM_IN_CHANNELS 2
- #define NUM_OUT_CHANNELS 2
- #define NUM_SAMPLES 44100
- float inbuf[NUM_SAMPLES * NUM_IN_CHANNELS];
- float outbuf[NUM_SAMPLES * NUM_OUT_CHANNELS];
- //[[/Declarations]]
- //[[Instances]]
- //[[/Instances]]
- //[[Processing]]
- int audio_buffer_process()
- {
- int nBufferFrames = NUM_SAMPLES;
- float *in = inbuf;
- float *out = outbuf;
- while(nBufferFrames-- > 0) {
- // Starting stream 00 -------------------------
- // Stream End 00
- // Starting stream 00 -------------------------
- float _bundle_connector_58[2];
- _bundle_connector_58[0] = OuterCounter;
- _bundle_connector_58[1] = 20;
- Equal_014.process__OutputDomain(_bundle_connector_58, _Equal_014_out);
- ResetOuter = _Equal_014_out;
- if (ResetOuter) {
- Loop_process_AudioDomain(Accum);
- }
- // Stream End 00
- // Starting stream 01 -------------------------
- if (ResetOuter) {
- _OuterCounterReset_process_AudioDomain(OuterCounter);
- }
- // Stream End 01
- // Starting stream 02 -------------------------
- OuterCounter = (OuterCounter + 1);
- // Stream End 02
- // Starting stream 03 -------------------------
- //#line 25 "/home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/loop/01_simple.stride"
- out[0] = Accum;;
- // Stream End 03
- in += NUM_IN_CHANNELS;
- out += NUM_OUT_CHANNELS;
- }
- return 0;
- }
- //[[/Processing]]
- //[[OSC:Processing]]
- //[[/OSC:Processing]]
- //[[SerialIn:Processing]]
- //[[/SerialIn:Processing]]
- //[[SerialOut:Processing]]
- //[[/SerialOut:Processing]]
- int main() {
- //[[Initialization]]
- Accum = 0;
- OuterCounter = 0;
- ResetOuter = false;
- AudioOut[0] = 0.0;
- AudioOut[1] = 0.0;
- for(int i = 0; i < NUM_SAMPLES; i++) {
- inbuf[i* NUM_IN_CHANNELS] = (i * 2.0 / (NUM_SAMPLES-1)) - 1; // -1 -> 1
- inbuf[i* NUM_IN_CHANNELS + 1] = 1 - (i * 2.0 / (NUM_SAMPLES-1)); // 1 -> -1
- }
- audio_buffer_process();
- //[[/Initialization]]
- // char input;
- // std::cout << "\nRunning ... press <enter> to quit.\n";
- // std::cin.get(input);
- //[[Cleanup]]
- for(int i = 0; i < NUM_SAMPLES; i++) {
- std::cout << std::setprecision(10) << outbuf[i] << std::endl;
- }
- //[[/Cleanup]]
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement