diff --git src/cond.pri src/cond.pri index f0ee939..a8892d0 100644 --- src/cond.pri +++ src/cond.pri @@ -24,7 +24,7 @@ DEFINES += HAS_ALSA # Comment this line if you don't have libinstpatch installed on your system # You won't be able to export sf2 files (nor future DLS and GIGA) -#DEFINES += HAS_LIBINSTPATCH +DEFINES += HAS_LIBINSTPATCH # Comment this line if you don't have aubio installed on your system # The aubio beatmatching algorithms won't be available, only the freecycle ones. @@ -43,6 +43,7 @@ INCLUDEPATH += /usr/include/glib-2.0 INCLUDEPATH += /usr/lib/glib-2.0/include INCLUDEPATH += /opt/gnome/lib/glib-2.0/include INCLUDEPATH += /usr/include/libinstpatch-1.0 +INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include ################ STATIC LINK SETTINGS ############### diff --git src/dlsmanager.cpp src/dlsmanager.cpp index 9783b43..daa0b92 100644 --- src/dlsmanager.cpp +++ src/dlsmanager.cpp @@ -27,7 +27,7 @@ void DLSManager::writeDLS2File(QString path_and_filename,QStringList* filenames, char nb_keygroups=filenames->size(); qHeapSort(bld); - IpatchFile *file; + IpatchFileHandle *file; IpatchDLSFile *dlsfile; IpatchDLS2Sample *sample; GError *err = NULL; @@ -56,7 +56,7 @@ void DLSManager::writeDLS2File(QString path_and_filename,QStringList* filenames, continue; } /* identify and open file (++ new object reference) */ - file = ipatch_file_identify_open (temp_filename.ascii(), "r", &err); + file = ipatch_file_identify_open (temp_filename.ascii(), &err); if (!file){ fprintf (stderr, "Failed to identify file '%s': %s\n", temp_filename.ascii(), ipatch_gerror_message (err)); diff --git src/gigamanager.cpp src/gigamanager.cpp index 99b0934..0c3baf2 100644 --- src/gigamanager.cpp +++ src/gigamanager.cpp @@ -26,7 +26,7 @@ void GigaManager::writeGigaFile(QString path_and_filename,QStringList* filenames QString dirpath=QFileInfo(path_and_filename).dirPath(); char nb_keygroups=filenames->size(); qHeapSort(bld); - IpatchFile *file; + IpatchFileHandle *file; IpatchGigFile *gigfile; IpatchGigInst *inst; IpatchGigSample *sample; @@ -55,7 +55,7 @@ void GigaManager::writeGigaFile(QString path_and_filename,QStringList* filenames continue; } /* identify and open file (++ new object reference) */ - file = ipatch_file_identify_open (temp_filename.ascii(), "r", &err); + file = ipatch_file_identify_open (temp_filename.ascii(), &err); if (!file){ fprintf (stderr, "Failed to identify file '%s': %s\n", temp_filename.ascii(), ipatch_gerror_message (err)); diff --git src/sf2manager.cpp src/sf2manager.cpp index e819bc8..c930507 100644 --- src/sf2manager.cpp +++ src/sf2manager.cpp @@ -36,7 +36,7 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, char nb_keygroups=filenames->size(); qHeapSort(bld); - IpatchFile *file; + IpatchFileHandle *file; IpatchSF2File *sffile; IpatchSF2Sample *sample; IpatchSF2Inst *inst; @@ -50,16 +50,6 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, inst = ipatch_sf2_inst_new (); /* set instrument name */ ipatch_sf2_inst_set_name(inst, filename.ascii()); - /* append instrument to SoundFont (ensure that its name is unique) */ - ipatch_container_add_unique (IPATCH_CONTAINER (sf2),IPATCH_ITEM (inst)); - /* create new SoundFont preset (++ ref) */ - preset = ipatch_sf2_preset_new (); - /* set preset name */ - ipatch_sf2_preset_set_name(preset,filename.ascii()); - /* append preset to SoundFont (ensure name/bank/preset # are unique) */ - ipatch_container_add_unique (IPATCH_CONTAINER (sf2),IPATCH_ITEM (preset)); - /* create new preset zone and link instrument to it */ - ipatch_sf2_preset_new_zone (preset, inst); @@ -72,7 +62,7 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, continue; } /* identify and open file (++ new object reference) */ - file = ipatch_file_identify_open (temp_filename.ascii(), "r", &err); + file = ipatch_file_identify_open (temp_filename.ascii(), &err); if (!file){ fprintf (stderr, "Failed to identify file '%s': %s\n", temp_filename.ascii(), ipatch_gerror_message (err)); @@ -82,7 +72,7 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, /* attempt to convert sample file to SoundFont sample object * ++ ref */ - sample = (IpatchSF2Sample *)ipatch_convert_object_to_type (G_OBJECT (file), IPATCH_TYPE_SF2_SAMPLE, &err); + sample = (IpatchSF2Sample *)ipatch_convert_object_to_type (G_OBJECT (file->file), IPATCH_TYPE_SF2_SAMPLE, &err); if (!sample) { @@ -90,47 +80,47 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, temp_filename.ascii(), ipatch_gerror_message (err)); g_clear_error (&err); - g_object_unref (file); /* remove file reference */ + g_object_unref (file->file); /* remove file reference */ continue; } /* append sample to SoundFont (ensure that its name is unique) */ - ipatch_container_add_unique (IPATCH_CONTAINER (sf2), - IPATCH_ITEM (sample)); + ipatch_container_add_unique (IPATCH_CONTAINER (sf2), IPATCH_ITEM (sample)); g_object_set (sample, "root-note", midiNote, NULL); /* set the sample's root-note */ /* create new instrument zone and link sample to it */ - //ipatch_sf2_inst_new_zone(inst,sample); - IpatchSF2IZone *izone= ipatch_sf2_izone_new (); - ipatch_sf2_zone_set_link_item (IPATCH_SF2_ZONE (izone), IPATCH_ITEM (sample)); - //ipatch_sf2_gen_item_set_note_range(IPATCH_ITEM (izone),midiNote,midiNote); - //ipatch_sf2_gen_item_set_velocity_range(IPATCH_ITEM (izone),0,127); - ipatch_container_append (IPATCH_CONTAINER (inst), IPATCH_ITEM (izone)); - g_object_unref (izone); - - /* - IpatchSF2IZone* zone=ipatch_sf2_izone_new(); - ipatch_sf2_zone_set_link_item (IPATCH_SF2_ZONE (zone), IPATCH_ITEM (sample)); - */ + ipatch_sf2_izone_set_sample(izone,sample); IpatchRange* range=ipatch_range_new (midiNote, midiNote); - g_object_set(izone,"key-range", range, NULL); - ipatch_range_free(range); - g_object_unref(izone); - /**/ + g_object_set(izone,"note-range", range, NULL); + ipatch_container_add_unique (IPATCH_CONTAINER (inst), IPATCH_ITEM (izone)); - g_object_unref (sample); /* -- unref SoundFont sample */ - g_object_unref (file); /* -- unref file */ + /* -- unref objects */ + ipatch_range_free(range); + g_object_unref(izone); + g_object_unref (sample); + ipatch_file_close(file); } + + /* append instrument to SoundFont (ensure that its name is unique) */ + ipatch_container_add_unique (IPATCH_CONTAINER (sf2),IPATCH_ITEM (inst)); + /* create new SoundFont preset (++ ref) */ + preset = ipatch_sf2_preset_new (); + /* set preset name */ + ipatch_sf2_preset_set_name(preset,filename.ascii()); + /* create new preset zone and link instrument to it */ + ipatch_sf2_preset_new_zone (preset, inst); + /* append preset to SoundFont (ensure name/bank/preset # are unique) */ + ipatch_container_add_unique (IPATCH_CONTAINER (sf2),IPATCH_ITEM (preset)); g_object_unref (inst); /* -- unref SoundFont instrument */ g_object_unref (preset); - + /* create SoundFont file object, set its name and open for writing */ sffile = ipatch_sf2_file_new (); - - if (!ipatch_file_open (IPATCH_FILE (sffile), QString(dirpath+"/"+filename+".sf2").ascii(), "w", &err)){ + ipatch_file_set_name(IPATCH_FILE(sffile), QString(dirpath+"/"+filename+".sf2").ascii()); + if (!sffile){ fprintf (stderr, "Failed to open output file for writing: %s\n", ipatch_gerror_message (err)); @@ -141,27 +131,15 @@ void SF2Manager::writeSF2File(QString path_and_filename ,QStringList* filenames, } /* convert SoundFont object to SoundFont file (write it) */ - /* + if (!ipatch_convert_objects (G_OBJECT (sf2), G_OBJECT (sffile), &err)) { fprintf (stderr, "Failed to save SoundFont to file: %s\n", ipatch_gerror_message (err)); g_clear_error (&err); } - */ - - IpatchSF2Writer* writer=ipatch_sf2_writer_new(sffile,sf2); - if (!ipatch_sf2_writer_save(writer,&err)) - { - fprintf (stderr, "Failed to save SoundFont to file: %s\n", - ipatch_gerror_message (err)); - g_clear_error (&err); - } - - + fprintf (stderr, "finished writing file. about to unref objects.\n"); g_object_unref (sffile); /* -- unref SoundFont file */ g_object_unref (sf2); /* -- unref SoundFont object */ - - //return (0); /* we done, yeah! :) */ }