static void unity2dQtHandler(QtMsgType type, const char *message) { static QByteArray name = QCoreApplication::applicationFilePath().section("/", -1).toLocal8Bit(); static bool useTimeStamp = getenvBool("UNITY2D_DEBUG_TIMESTAMP", false); // We use fputs here because we don't want stderr to be flushed before the // end of the line if (useTimeStamp) { QString timeStr = QTime::currentTime().toString("HH:mm:ss.zzz: "); fputs(qPrintable(timeStr), stderr); } fputs(name.constData(), stderr); fputs(": ", stderr); switch (type) { case QtDebugMsg: unity2dQtHandlerPrint(COLOR_BLUE, "DEBUG", message); break; case QtWarningMsg: unity2dQtHandlerPrint(COLOR_RED, "WARNING", message); break; case QtCriticalMsg: unity2dQtHandlerPrint(COLOR_RED, "CRITICAL", message); break; case QtFatalMsg: unity2dQtHandlerPrint(COLOR_RED, "FATAL", message); abort(); } }
static void unity2dQtHandlerPrint(const char* color, const char* level, const char* message) { static bool useColor = isatty(fileno(stderr)) && getenvBool("UNITY2D_DEBUG_COLOR", true); if (useColor) { fprintf(stderr, "%s[%s]\033[0m %s\n", color, level, message); } else { fprintf(stderr, "[%s] %s\n", level, message); } }
//----------------------------------------------------------------------------- VstChunk::VstChunk(long numParameters, long numPrograms, long magic, AudioEffectX *effect, unsigned long sizeofExtendedData) : numParameters(numParameters), numPrograms(numPrograms), effect(effect), sizeofExtendedData(sizeofExtendedData) { sharedChunk = 0; paramAssignments = 0; parameterIDs = 0; // there's nothing we can do without a pointer back to the effect if (effect == NULL) return; effect->programsAreChunks(); // tell host you will want to use chunks if (numPrograms < 1) numPrograms = 1; // we do need at least 1 set of parameters if (numParameters < 1) numParameters = 1; // come on now, what are you trying to do? paramAssignments = (ParameterAssignment*) malloc(numParameters * sizeof(ParameterAssignment)); parameterIDs = (long*) malloc(numParameters * sizeof(long)); // default to each parameter having its ID equal its index // (I haven't implemented anything with parameter IDs yet) for (long i=0; i < numParameters; i++) parameterIDs[i] = i; // calculate some data sizes that are useful to know sizeofProgram = sizeof(Program) + (sizeof(float) * (numParameters-2)); sizeofParameterIDs = sizeof(long) * numParameters; sizeofPresetChunk = sizeofProgram // 1 program + sizeof(ChunkInfo) // the special chunk header info + sizeofParameterIDs; // the table of parameter IDs sizeofChunk = (sizeofProgram*numPrograms) // all of the programs + sizeof(ChunkInfo) // the special chunk header info + sizeofParameterIDs // the table of parameter IDs + (sizeof(ParameterAssignment)*numParameters); // the MIDI events assignment array // increase the allocation sizes if extra data must be stored sizeofChunk += sizeofExtendedData; sizeofPresetChunk += sizeofExtendedData; // this is the shared data that we point **data to in getChunk() sharedChunk = (ChunkInfo*) malloc(sizeofChunk); // & a few pointers to elements within that data, just for ease of use firstSharedParameterID = (long*) ((char*)sharedChunk + sizeof(ChunkInfo)); firstSharedProgram = (Program*) ((char*)firstSharedParameterID + sizeofParameterIDs); firstSharedParamAssignment = (ParameterAssignment*) ((char*)firstSharedProgram + (sizeofProgram*numPrograms)); // set all of the header infos chunkInfo.magic = magic; chunkInfo.version = effect->getVendorVersion(); chunkInfo.lowestLoadableVersion = 0; chunkInfo.storedHeaderSize = sizeof(ChunkInfo); chunkInfo.numStoredParameters = numParameters; chunkInfo.numStoredPrograms = numPrograms; chunkInfo.storedParameterAssignmentSize = sizeof(ParameterAssignment); chunkInfo.storedExtendedDataSize = sizeofExtendedData; clearAssignments(); // initialize all of the parameters to have no MIDI event assignments resetLearning(); // start with MIDI learn mode off // default to allowing MIDI event assignment sharing instead of stealing them, // unless the user has defined the environment variable DFX_PARAM_STEALMIDI stealAssignments = getenvBool("DFX_PARAM_STEALMIDI", false); // default to ignoring MIDI channel in MIDI event assignments and automation, // unless the user has defined the environment variable DFX_PARAM_USECHANNEL useChannel = getenvBool("DFX_PARAM_USECHANNEL", false); // default to not allowing MIDI note or pitchbend events to be assigned to parameters allowNoteEvents = false; allowPitchbendEvents = false; noteRangeHalfwayDone = false; // default to trying to load un-matching chunks crisisBehaviour = kCrisisLoadWhatYouCan; // allow for further constructor stuff, if necessary init(); }