Mercurial > hg > beaglert
comparison core/default_libpd_render.cpp @ 470:5a936f8e9447 prerelease
I mean it actually works for real. Libpd checks for file and exits with meaningful error message if it does not find it.
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 20 Jun 2016 18:04:11 +0100 |
parents | 03a2cd5f151b |
children | efc9a9f8e63d |
comparison
equal
deleted
inserted
replaced
468:85cf9c0da052 | 470:5a936f8e9447 |
---|---|
125 static unsigned int gLibpdBlockSize; | 125 static unsigned int gLibpdBlockSize; |
126 static unsigned int gChannelsInUse = 26; | 126 static unsigned int gChannelsInUse = 26; |
127 | 127 |
128 bool setup(BelaContext *context, void *userData) | 128 bool setup(BelaContext *context, void *userData) |
129 { | 129 { |
130 // Check first of all if file exists. Will actually open it later. | |
131 char file[] = "_main.pd"; | |
132 char folder[] = "./"; | |
133 unsigned int strSize = strlen(file) + strlen(folder) + 1; | |
134 char* str = (char*)malloc(sizeof(char) * strSize); | |
135 snprintf(str, strSize, "%s%s", folder, file); | |
136 if(access(str, F_OK) == -1 ) { | |
137 printf("Error file %s/%s not found. The %s file should be your main patch.\n", folder, file, file); | |
138 return false; | |
139 } | |
130 dcm.setCallback(sendDigitalMessage); | 140 dcm.setCallback(sendDigitalMessage); |
131 analogChannelsInUse = min(context->analogChannels, gChannelsInUse - context->audioChannels - context->digitalChannels); | 141 analogChannelsInUse = min(context->analogChannels, gChannelsInUse - context->audioChannels - context->digitalChannels); |
132 if(context->digitalChannels > 0){ | 142 if(context->digitalChannels > 0){ |
133 for(unsigned int ch = 0; ch < context->digitalChannels; ++ch){ | 143 for(unsigned int ch = 0; ch < context->digitalChannels; ++ch){ |
134 dcm.setCallbackArgument(ch, receiverNames[ch]); | 144 dcm.setCallbackArgument(ch, receiverNames[ch]); |
187 libpd_bind("bela_digitalOut24"); | 197 libpd_bind("bela_digitalOut24"); |
188 libpd_bind("bela_digitalOut25"); | 198 libpd_bind("bela_digitalOut25"); |
189 libpd_bind("bela_digitalOut26"); | 199 libpd_bind("bela_digitalOut26"); |
190 libpd_bind("bela_setDigital"); | 200 libpd_bind("bela_setDigital"); |
191 | 201 |
192 char file[] = "_main.pd"; | |
193 char folder[] = "./"; | |
194 // open patch [; pd open file folder( | 202 // open patch [; pd open file folder( |
195 libpd_openfile(file, folder); | 203 void* patch = libpd_openfile(file, folder); |
204 if(patch == NULL){ | |
205 printf("Error: file %s/%s is corrupted.\n", folder, file); | |
206 return false; | |
207 } | |
196 libpdReadFilesTask = Bela_createAuxiliaryTask(libpdReadFilesLoop, 60, "libpdReadFiles"); | 208 libpdReadFilesTask = Bela_createAuxiliaryTask(libpdReadFilesLoop, 60, "libpdReadFiles"); |
197 Bela_scheduleAuxiliaryTask(libpdReadFilesTask); | 209 Bela_scheduleAuxiliaryTask(libpdReadFilesTask); |
198 | 210 |
199 | 211 |
200 return true; | 212 return true; |