Browse Source

New cbox

master
Nils 12 months ago
parent
commit
4dd7212d46
  1. 1
      template/calfbox/py/nullbox.py
  2. 6
      template/calfbox/sampler_prg.c
  3. 10
      template/calfbox/tarfile.c
  4. 18
      template/calfbox/wavebank.c

1
template/calfbox/py/nullbox.py

@ -21,7 +21,6 @@ class NullCalfbox(str): #iterable
self.patch = {i:(0, "nullbox") for i in range(1,17)} #catches status().patch
self.frame_rate = 48000
self.frame = 0
self.gain = 0
def __getattr__(self, *args, **kwargs):
return __class__()

6
template/calfbox/sampler_prg.c

@ -309,7 +309,6 @@ struct sampler_program *sampler_program_new_from_cfg(struct sampler_module *m, c
sfz = cfg_section + 6;
if (!strncmp(sfz, "sbtar:", 6))
{
sfz_path = ".";
gchar *p = strchr(sfz + 6, ';');
if (p)
{
@ -318,8 +317,11 @@ struct sampler_program *sampler_program_new_from_cfg(struct sampler_module *m, c
g_free(tmp);
if (!tarfile)
return NULL;
sfz = p + 1;
sfz = strrchr(p + 1, '/');
if (!sfz)
sfz = p + 1;
name2 = p + 1;
sfz_path = g_path_get_dirname(p + 1);
}
else
{

10
template/calfbox/tarfile.c

@ -49,7 +49,7 @@ struct tar_record
char padding[12];
};
static void remove_item_if(gpointer p);
static void remove_item_if(gpointer p, struct cbox_tarfile *tf);
struct cbox_tarfile *cbox_tarfile_open(const char *pathname, GError **error)
{
@ -118,8 +118,8 @@ struct cbox_tarfile *cbox_tarfile_open(const char *pathname, GError **error)
ti->refs = 2;
// Overwrite old items by the same name and/or same case-folded name
remove_item_if(g_hash_table_lookup(tf->items_byname, ti->filename));
remove_item_if(g_hash_table_lookup(tf->items_byname_nc, ti->filename_nc));
remove_item_if(g_hash_table_lookup(tf->items_byname, ti->filename), tf);
remove_item_if(g_hash_table_lookup(tf->items_byname_nc, ti->filename_nc), tf);
g_hash_table_insert(tf->items_byname, ti->filename, ti);
g_hash_table_insert(tf->items_byname_nc, ti->filename_nc, ti);
@ -154,7 +154,7 @@ error:
return NULL;
}
void remove_item_if(gpointer p)
void remove_item_if(gpointer p, struct cbox_tarfile *tf)
{
if (!p)
return;
@ -163,6 +163,8 @@ void remove_item_if(gpointer p)
// If all references (by name and by case-folded name) gone, remove the item
if (!--ti->refs)
{
g_hash_table_remove(tf->items_byname, ti->filename);
g_hash_table_remove(tf->items_byname_nc, ti->filename_nc);
g_free(ti->filename);
g_free(ti->filename_nc);
free(ti);

18
template/calfbox/wavebank.c

@ -324,24 +324,6 @@ struct cbox_waveform *cbox_wavebank_get_waveform(const char *context_name, struc
struct cbox_taritem *taritem = NULL;
if (tarfile)
{
if (strcmp(sample_dir, ".") == 0)
{
//Potential path lookup problem:
//This is a sample without sfz default_path opcode inside a tar.
//We need to set the sample dir to the position of the .sfz file within the .tar
//because we also assume that the sample paths in regions are relative to the .sfz path.
//If the sfz is in the tar root this is a redundant action, but if the sfz is itself
//in a subdirectoy we need to adjust the path now.
// XXXNH sample_dir will not be updated in the struct itself and thus reported as "." in python etc.
//context_name is the sfz file, filename the sample file without leading ./ and sample_dir just a dot.
gchar *sfz_dir = g_path_get_dirname(context_name); //take the path of the sfz file...
pathname = g_build_filename(sfz_dir, filename, NULL); //... and prefix the sample filename with it.
g_free(sfz_dir);
}
taritem = cbox_tarfile_get_item_by_name(tarfile, pathname, TRUE);
if (taritem)
sndfile = cbox_tarfile_opensndfile(tarfile, taritem, &waveform->sndstream, &waveform->info);

Loading…
Cancel
Save