static void *create_plugin_data(const SoundPluginType *plugin_type, struct SoundPlugin *plugin, hash_t *state, float samplerate, int block_size){ //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/etrnpadl.xi"; // one sample //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/elecpad.xi"; // multile samples //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/flpad2.xi"; // multile samples //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/BIGPAD1.XI"; // multile samples //const char *filename="/home/kjetil/brenn/downloaded/temp/waveworld/wav/synths/temp/prophe07.wav"; //const char *filename="/gammelhd/home/kjetil/poing-imperatif/karin.wav"; //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/BASS/ACOUSTIC/acbs02r.xi"; //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/SEQUENCE/SH101/sh101sq1.xi"; //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/BELL/CHURCH/CHRBEL01.XI"; //const char *filename="/gammelhd/gammelhd/gammel_lyd/2_channel_short.wav"; //const char *filename="/gammelhd/gammelhd/gammelhd/gammel_lyd/d_lydfiler/instrument/keyboard/mellotron.sf2"; wchar_t *default_sound_filename = STRING_append(OS_get_program_path2(), STRING_append(STRING_create(OS_get_directory_separator()), STRING_append(STRING_create("sounds"), STRING_append(STRING_create(OS_get_directory_separator()), !strcmp(plugin_type->name, "Click") ? STRING_create("243749__unfa__metronome-1khz-weak-pulse.flac") : STRING_create("016.WAV"))))); Data *data = create_data(samplerate,NULL,default_sound_filename,0,RESAMPLER_CUBIC); // cubic is the default if(load_sample(data,default_sound_filename,0)==false){ free(data); return NULL; } return data; }
static void create_state(struct SoundPlugin *plugin, hash_t *state){ printf("\n\n\n ********** CREATE_STATE ************* \n\n\n"); Devdata *devdata = (Devdata*)plugin->data; HASH_put_string(state, "code", STRING_toBase64(STRING_create(devdata->code))); HASH_put_string(state, "options", STRING_toBase64(STRING_create(devdata->options))); }
void NewSong_CurrPos(struct Tracker_Windows *window){ //char temp[4098]; //sprintf(temp,"%s%s%s",OS_get_program_path(), OS_get_directory_separator(), "new_song.rad"); //Load_CurrPos_org(window,talloc_strdup(temp)); Load_CurrPos_org(window, OS_get_full_program_file_path(STRING_create("new_song.rad"))); GFX_SetWindowTitle(root->song->tracker_windows, STRING_create("Radium - New song.")); dc.filename=NULL; }
void saveBlock(const char *filename, int blocknum, int windownum){ struct Tracker_Windows *window; struct WBlocks *wblock; wblock=getWBlockFromNumA( windownum, &window, blocknum ); if(wblock==NULL) return; if (filename==NULL || !strcmp(filename, "")) filename = "/tmp/block.block"; if (Save_Initialize(STRING_create(filename), "RADIUM BLOCK")==false) return; SaveWBlock(wblock); SaveBlock(wblock->block); if( ! dc.success){ handleError("Problems writing to file.\n"); } DISK_close_and_delete(dc.file); }
static void *create_plugin_data(const SoundPluginType *plugin_type, struct SoundPlugin *plugin, hash_t *state, float samplerate, int block_size){ //Data *data = create_data("/home/kjetil/SGM-V2.01.sf2",samplerate); wchar_t *default_sound_filename = STRING_append(OS_get_program_path2(), STRING_append(STRING_create(OS_get_directory_separator()), STRING_append(STRING_create("sounds"), STRING_append(STRING_create(OS_get_directory_separator()), STRING_create("Orgue.sf2"))))); Data *data = create_data(default_sound_filename, samplerate); if(data!=NULL){ fluid_synth_bank_select(data->synth,0,0); fluid_synth_program_change(data->synth,0,0); } return data; }
wchar_t *DISK_read_wchar_line(disk_t *disk){ QString line = DISK_read_qstring_line(disk); if (line==g_file_at_end) return NULL; return STRING_create(line); }
const char *getSaveFilename(char *text, char *filetypes, char *dir){ struct Tracker_Windows *window=getWindowFromNum(-1);if(window==NULL) return ""; const wchar_t *ret = GFX_GetSaveFileName(window, NULL, text, STRING_create(dir), filetypes); if(ret==NULL) return ""; else return STRING_get_chars(ret); }
wchar_t *FLUIDSYNTH_get_filename_display(struct SoundPlugin *plugin){ Data *data=(Data*)plugin->data; char *s2 = talloc_format(", b: %d, p: %d", data->bank_num, data->preset_num); return STRING_append(data->filename, STRING_create(s2)); }
wchar_t *DISK_close_temp_for_writing(disk_t *disk){ GFX_Message(NULL, "Warning, never tested"); disk->close(); QByteArray data = disk->temporary_write_file->readAll(); wchar_t *ret = STRING_create(data.toUtf8().constData()); delete disk; return ret; }
// Only used for audio files, so we don't bother with decompression. const wchar_t *DISK_base64_to_file(const wchar_t *wfilename, const char *chars){ QFile *file; QTemporaryFile *temporary_write_file = NULL; QFile outfile; QByteArray data = QByteArray::fromBase64(chars); if (wfilename==NULL) { temporary_write_file = new QTemporaryFile; file = temporary_write_file; } else { outfile.setFileName(STRING_get_qstring(wfilename)); file = &outfile; } if (file->open(QIODevice::WriteOnly)==false){ GFX_Message(NULL, "Unable to open file \"%s\" (%s)", file->fileName().toUtf8().constData(), file->errorString().toUtf8().constData()); return NULL; } if (file->write(data) != data.size()){ GFX_Message(NULL, "Unable to write to file \"%s\" (%s)", file->fileName().toUtf8().constData(), file->errorString().toUtf8().constData()); file->close(); return NULL; } file->close(); if (wfilename==NULL){ radium::ScopedMutex lock(&g_mutex); g_temporary_files[temporary_write_file->fileName()] = temporary_write_file; } return STRING_create(file->fileName()); }
void CRASHREPORTER_send_message(const char *additional_information, const char **messages, int num_messages, Crash_Type crash_type){ QString plugin_names = get_plugin_names(); QString tosend = QString(additional_information) + "\n\n"; tosend += VERSION "\n\n"; tosend += "OpenGL vendor: " + QString((GE_vendor_string==NULL ? "(null)" : (const char*)GE_vendor_string )) + "\n"; tosend += "OpenGL renderer: " + QString((GE_renderer_string==NULL ? "(null)" : (const char*)GE_renderer_string)) + "\n"; tosend += "OpenGL version: " + QString((GE_version_string==NULL ? "(null)" : (const char*)GE_version_string)) + "\n"; tosend += QString("OpenGL flags: %1").arg(GE_opengl_version_flags, 0, 16) + "\n\n"; tosend += "Running plugins: " + plugin_names + "\n\n"; tosend += "Running time: " + QString::number(running_time.elapsed()) + "\n\n"; tosend += "\n\n"; for(int i=0;i<num_messages;i++) tosend += QString::number(i) + ": "+messages[i] + "\n"; tosend += "\n\n"; int event_pos = g_event_pos; tosend += "start event_pos: " + QString::number(event_pos) + "\n"; for(int i=event_pos-1; i>=0 ; i--) tosend += QString(g_event_log[i]) + "\n"; for(int i=NUM_EVENTS-1; i>=event_pos ; i--) tosend += QString(g_event_log[i]) + "\n"; tosend += "end event_pos: " + QString::number(g_event_pos) + "\n"; tosend += "\n\n"; #if defined(FOR_LINUX) tosend += "LINUX\n\n"; tosend += "/etc/os-release: "+file_to_string("/etc/os-release"); tosend += "\n\n"; tosend += "/proc/version: "+file_to_string("/proc/version"); tosend += "\n\n"; tosend += "/proc/cpuinfo: "+file_to_string("/proc/cpuinfo"); #endif // start process { QString program = QCoreApplication::applicationDirPath() + QDir::separator() + "crashreporter"; #if FOR_WINDOWS program += ".exe"; #endif QTemporaryFile *file; if (crash_type==CT_CRASH) { file = new QTemporaryFile; } else { if (g_crashreporter_file==NULL) { g_crashreporter_file = new QTemporaryFile; g_crashreporter_file->setAutoRemove(false); // We delete it in the sub process. This process is just going to exit as soon as possible. } file = g_crashreporter_file; } bool save_mixer_tree; if (crash_type==CT_CRASH) save_mixer_tree = false; // Don't want to risk crashing inside the crash handler. else save_mixer_tree = true; string_to_file(tosend, file, save_mixer_tree); /* Whether to block ================ RELEASE !RELEASE ------------------------- Crash in main thread | no [1] yes [2] Crash in other thread | no [1] yes [2] Assert in main thread | no [4] yes [2] Assert in other thread | no [4] yes [2,3] [1] When crashing in RELEASE mode, it doesn't matter wheter we block or not, because radium will exit immediately after finishing this function anyway, and it's probably better to do that as quickly as possible. [2] Ideally, this should happen though: 1. All threads immediately freezes 2. A dialog pops up asking whether to: a) Stop program (causing gdb to kick in) b) Ignore c) Run assert crashreporter [3] This can be annoying if the assert happens in the audio thread though. [4] Asserts are not really supposed to happen, but there are a lot of them, and they might pop up unnecessarily (for instance a bug in the asserts themselves): * Blocking might cause the program to be non-functional unnecessarily. * Blocking could prevent the user from saving the current song, for instance if the assert window just pops up immediately after closing it. */ #ifdef RELEASE bool do_block = false; #else bool do_block = true; #endif QTemporaryFile emergency_save_file("radium_crash_save"); #if 0 bool dosave = is_crash && Undo_num_undos_since_last_save()>0; #else bool dosave = false; // saving inside a forked version of the program didn't really work that well. Maybe it works better in windows. #endif if (dosave) emergency_save_file.open(); run_program(program, toBase64(file->fileName()), toBase64(plugin_names), toBase64(dosave ? emergency_save_file.fileName() : NOEMERGENCYSAVE), crash_type==CT_CRASH ? "is_crash" : crash_type==CT_ERROR ? "is_error" : "is_warning", do_block ); if (dosave) Save_Clean(STRING_create(emergency_save_file.fileName()),root,false); } }
static wchar_t *get_backup_filename(void){ return STRING_append(dc.filename, STRING_create("_automatic_backup.rad")); }
wchar_t *DISK_get_filename(disk_t *disk){ return STRING_create(disk->filename); }
static bool Load_CurrPos_org(struct Tracker_Windows *window, const wchar_t *filename){ bool ret = false; // So many things happen here, that we should turn off garbage collection while loading. // // For instance, the instrument widget contains pointers (which are unreachable from the GC) to Patch // and PatchData objects. The instrument widget is updated after setting a new root, so it may access // that memory while a new song is loaded (since we don't have control over what Qt may do while we // access it). Not unlikely to be other similar situations. if(0){ GC_disable(); } PlayStop(); if(Undo_are_you_shure_questionmark()==false) goto exit; if(filename==NULL) filename=GFX_GetLoadFileName(window,NULL,"Select file to load", NULL, NULL); if(filename==NULL) goto exit; if (STRING_ends_with(filename,".MMD2") || STRING_ends_with(filename,".MMD3") || STRING_ends_with(filename,".MMD") || STRING_ends_with(filename,".mmd2") || STRING_ends_with(filename,".mmd3") || STRING_ends_with(filename,".mmd") ) { mmp2filename=filename; ret = Load(STRING_create("new_song.rad")); } else { OS_set_loading_path(filename); { ret = Load(filename); } OS_unset_loading_path(); GFX_SetWindowTitle(root->song->tracker_windows, filename); GFX_EditorWindowToFront(root->song->tracker_windows); struct WBlocks *wblock = root->song->tracker_windows->wblock; GFX_update_instrument_patch_gui(wblock->wtrack->track->patch); DrawUpTrackerWindow(root->song->tracker_windows); fprintf(stderr,"Got here (loading finished)\n"); } exit: if(0){ GC_enable(); } if(mmp2filename!=NULL) { LoadMMP2(root->song->tracker_windows, mmp2filename); mmp2filename=NULL; } if (ret) ResetUndo(); return ret; }
void loadBlock(const char *filename_c){ struct Tracker_Windows *window=getWindowFromNum(-1);if(window==NULL) return; bool success = false; bool have_made_undo = false; if (filename_c==NULL || !strcmp(filename_c, "")) filename_c = "/tmp/block.block"; const wchar_t *filename = STRING_create(filename_c); int num_blocks = root->song->num_blocks; if (Load_Initialize(filename, "RADIUM BLOCK")==false) { goto exit; return; } if(strcmp(dc.ls,"WBLOCK")){ handleError("Loading failed.\nExpected \"WBLOCK\", but found instead: '%s'.\nFile: '%s'\n",dc.ls,STRING_get_chars(filename)); DISK_close_and_delete(dc.file); goto exit; return; } struct WBlocks *wblock = LoadWBlock(); wblock->l.num = num_blocks; DC_Next(); if(strcmp(dc.ls,"BLOCK")){ handleError("Loading failed.\nExpected \"BLOCK\", but found instead: '%s'.\nFile: '%s'\n",dc.ls,STRING_get_chars(filename)); DISK_close_and_delete(dc.file); goto exit; } struct Blocks *block = LoadBlock(); block->l.num = num_blocks; DISK_close_and_delete(dc.file); if(!dc.success){ handleError("Loading failed.\n"); goto exit; } printf("Got it: %p / %p\n",wblock,block); ADD_UNDO(Block_Insert(num_blocks)); have_made_undo = true; /* DC_ListAdd1(&root->song->blocks,block); DC_ListAdd1(&root->song->tracker_windows->wblocks, wblock); */ wblock->block = block; window->curr_track = 0; DLoadBlocks(root, block); DLoadWBlocks(window, window, wblock); CB_PasteBlock(window, wblock, window->wblock); success = true; exit: if (success==false) if (have_made_undo) Undo_CancelLastUndo(); }