Mercurial > hg > beaglert
comparison examples/basic_libpd/render.cpp @ 301:e4392164b458 prerelease
RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 14:34:41 +0100 |
parents | dbeed520b014 |
children | 1feb9c23ac57 |
comparison
equal
deleted
inserted
replaced
300:dbeed520b014 | 301:e4392164b458 |
---|---|
3 * | 3 * |
4 * Created on: Oct 24, 2014 | 4 * Created on: Oct 24, 2014 |
5 * Author: parallels | 5 * Author: parallels |
6 */ | 6 */ |
7 | 7 |
8 #include <BeagleRT.h> | 8 #include <Bela.h> |
9 #include <cmath> | 9 #include <cmath> |
10 #include <Utilities.h> | 10 #include <Utilities.h> |
11 #include <I2c_Codec.h> | 11 #include <I2c_Codec.h> |
12 #include <PRU.h> | 12 #include <PRU.h> |
13 #include <stdio.h> | 13 #include <stdio.h> |
32 | 32 |
33 void pdnoteon(int ch, int pitch, int vel) { | 33 void pdnoteon(int ch, int pitch, int vel) { |
34 printf("noteon: %d %d %d\n", ch, pitch, vel); | 34 printf("noteon: %d %d %d\n", ch, pitch, vel); |
35 } | 35 } |
36 | 36 |
37 void BeagleRT_printHook(const char *recv){ | 37 void Bela_printHook(const char *recv){ |
38 rt_printf("%s", recv); | 38 rt_printf("%s", recv); |
39 } | 39 } |
40 | 40 |
41 UdpServer udpServer; | 41 UdpServer udpServer; |
42 | 42 |
47 usleep(1000); | 47 usleep(1000); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 AuxiliaryTask udpReadTask; | 51 AuxiliaryTask udpReadTask; |
52 bool setup(BeagleRTContext *context, void *userData) | 52 bool setup(BelaContext *context, void *userData) |
53 { | 53 { |
54 gChannelsInUse = min((int)(context->analogChannels+context->audioChannels), (int)gChannelsInUse); | 54 gChannelsInUse = min((int)(context->analogChannels+context->audioChannels), (int)gChannelsInUse); |
55 udpServer.bindToPort(1234); | 55 udpServer.bindToPort(1234); |
56 | 56 |
57 // check that we are not running with a blocksize smaller than DEFDACBLKSIZE | 57 // check that we are not running with a blocksize smaller than DEFDACBLKSIZE |
68 // fprintf(stderr, "Error: analog and audio sampling rates must be the same\n"); | 68 // fprintf(stderr, "Error: analog and audio sampling rates must be the same\n"); |
69 // return false; | 69 // return false; |
70 // } | 70 // } |
71 //following lines borrowed from libpd/samples/c/pdtest/pdtest.c | 71 //following lines borrowed from libpd/samples/c/pdtest/pdtest.c |
72 // init pd | 72 // init pd |
73 libpd_set_printhook(BeagleRT_printHook); // set this before calling libpd_init | 73 libpd_set_printhook(Bela_printHook); // set this before calling libpd_init |
74 libpd_set_noteonhook(pdnoteon); | 74 libpd_set_noteonhook(pdnoteon); |
75 libpd_init(); | 75 libpd_init(); |
76 //TODO: analyse the ASCII of the patch file and find the in/outs to use | 76 //TODO: analyse the ASCII of the patch file and find the in/outs to use |
77 libpd_init_audio(gChannelsInUse, gChannelsInUse, context->audioSampleRate); | 77 libpd_init_audio(gChannelsInUse, gChannelsInUse, context->audioSampleRate); |
78 | 78 |
89 char file[] = "_main.pd"; | 89 char file[] = "_main.pd"; |
90 char folder[] = "./"; | 90 char folder[] = "./"; |
91 // open patch [; pd open file folder( | 91 // open patch [; pd open file folder( |
92 libpd_openfile(file, folder); | 92 libpd_openfile(file, folder); |
93 | 93 |
94 udpReadTask = BeagleRT_createAuxiliaryTask(udpRead, 60, "udpReadTask"); | 94 udpReadTask = Bela_createAuxiliaryTask(udpRead, 60, "udpReadTask"); |
95 BeagleRT_scheduleAuxiliaryTask(udpReadTask); | 95 Bela_scheduleAuxiliaryTask(udpReadTask); |
96 return true; | 96 return true; |
97 } | 97 } |
98 | 98 |
99 // render() is called regularly at the highest priority by the audio engine. | 99 // render() is called regularly at the highest priority by the audio engine. |
100 // Input and output are given from the audio hardware and the other | 100 // Input and output are given from the audio hardware and the other |
101 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 101 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
102 // will be 0. | 102 // will be 0. |
103 BeagleRTContext *c; | 103 BelaContext *c; |
104 void render(BeagleRTContext *context, void *userData) | 104 void render(BelaContext *context, void *userData) |
105 { | 105 { |
106 static int inW = 0; | 106 static int inW = 0; |
107 static int outR = 0; | 107 static int outR = 0; |
108 /* | 108 /* |
109 * NOTE: if you are only using audio (or only analogs) and you are using interleaved buffers | 109 * NOTE: if you are only using audio (or only analogs) and you are using interleaved buffers |
178 } | 178 } |
179 | 179 |
180 // cleanup() is called once at the end, after the audio has stopped. | 180 // cleanup() is called once at the end, after the audio has stopped. |
181 // Release any resources that were allocated in setup(). | 181 // Release any resources that were allocated in setup(). |
182 | 182 |
183 void cleanup(BeagleRTContext *context, void *userData) | 183 void cleanup(BelaContext *context, void *userData) |
184 { | 184 { |
185 free(gInBuf); | 185 free(gInBuf); |
186 free(gOutBuf); | 186 free(gOutBuf); |
187 } | 187 } |