Commit c4a22e12 authored by Jaromír Mikeš's avatar Jaromír Mikeš

Imported Upstream version 0.0.2+20120606.gitd2f92c9

parent 6b49f658
......@@ -25,6 +25,9 @@ option (BuildForDebug "Include gdb debugging support" ON)
# DEBUG
set (BuildOptionsDebug "-O0 -ggdb" CACHE STRING "Debug build flags")
# RELEASE
set (BuildOptionsRelease "-O2" CACHE STRING "Release build flags")
# additional compiler flags
add_definitions(-Wall -Wextra)
......@@ -36,7 +39,7 @@ if (BuildForDebug)
else (BuildForDebug)
set (CMAKE_BUILD_TYPE "Release")
set (DEBUG 0)
set (CMAKE_C_FLAGS_RELEASE ${BuildOptionsBasic})
set (CMAKE_C_FLAGS_RELEASE ${BuildOptionsRelease})
message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: ${CMAKE_C_FLAGS_RELEASE}")
endif (BuildForDebug)
......
......@@ -323,7 +323,7 @@ void cb_menu_patch_add_default(GtkWidget* menu_item, gpointer data)
void cb_menu_patch_duplicate(GtkWidget* menu_item, gpointer data)
{
(void)menu_item;(void)data;
int val;
int id;
int cp;
if ((cp = patch_list_get_current_patch(PATCH_LIST(patch_list))) < 0)
......@@ -332,14 +332,14 @@ void cb_menu_patch_duplicate(GtkWidget* menu_item, gpointer data)
return;
}
if ((val = patch_duplicate(cp)) < 0)
if ((id = patch_duplicate(cp)) < 0)
{
msg_log(MSG_ERROR, "Failed to duplicate patch (%s).\n",
pf_error_str(pf_error_get()));
return;
}
patch_list_update(PATCH_LIST(patch_list), val, PATCH_LIST_PATCH);
patch_list_update(PATCH_LIST(patch_list), id, PATCH_LIST_PATCH);
}
......
......@@ -127,6 +127,11 @@ int main(int argc, char *argv[])
gtk_main();
/* shutdown... */
#if DEBUG
patch_summary_dump();
#endif
midi_stop();
driver_stop();
patch_shutdown();
......
......@@ -60,6 +60,7 @@ typedef struct _raw_box
GtkWidget* toggle_box;
GtkWidget* check;
GtkWidget* auto_preview;
GtkWidget* resample_checkbox;
GtkWidget* table;
/* table contains: */
......@@ -183,16 +184,25 @@ static void cb_preview(raw_box* rb)
if (!name)
return;
if (strchr(name, '.') == NULL)
{ /* FIXME: silly method of distiguishing files/folders.
see: man 3 stat
*/
return;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb->check)))
{
int samplerate = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(rb->samplerate));
mixer_preview(name, samplerate, rb->channels, get_format(rb));
mixer_preview(name, samplerate, rb->channels, get_format(rb),1);
}
else
{
mixer_preview(name, 0, 0, 0);
int resamp = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(rb->resample_checkbox));
mixer_preview(name, 0, 0, 0, resamp);
}
return;
......@@ -296,6 +306,15 @@ static raw_box* raw_box_new(GtkWidget* dialog)
gtk_widget_show(rb->auto_preview);
gtk_box_pack_start(GTK_BOX(rb->toggle_box), rb->auto_preview, FALSE,
FALSE, 0);
rb->resample_checkbox = gtk_check_button_new_with_label("Resample");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb->resample_checkbox),
FALSE);
gtk_widget_show(rb->resample_checkbox);
gtk_box_pack_start(GTK_BOX(rb->toggle_box), rb->resample_checkbox, FALSE,
FALSE, 0);
g_signal_connect(dialog, "selection-changed",
G_CALLBACK(selection_changed_cb), rb);
......
......@@ -47,6 +47,7 @@
#include "sync.h"
#include "lfo.h"
#include "midi_control.h"
void audio_settings_session_cb(jack_session_event_t *event, void *arg);
/* prototypes */
......@@ -64,7 +65,7 @@ static jack_port_t* midiport;
#ifdef HAVE_JACK_SESSION_H
/*static jack_session_event_t *session_event;*/
JackSessionCallback session_cb = 0;
JackSessionCallback session_cb = audio_settings_session_cb;
#endif
static jack_client_t* client;
......@@ -81,7 +82,7 @@ static bool autoconnect = true;
typedef jack_default_audio_sample_t jack_sample_t;
#ifdef HAVE_JACK_SESSION_H
void jackdriver_set_session_cb(JackSessionCallback jack_session_cb)
void jackdriver_set_session_cb(JackSessionCallback jack_session_cb) //UNUSED
{
session_cb = jack_session_cb;
}
......
......@@ -443,14 +443,16 @@ void mixer_direct_control(int chan, int param, float value, Tick tick)
void mixer_preview(char *name, int raw_samplerate,
int raw_channels,
int sndfile_format)
int sndfile_format,
int resample_sndfile)
{
pthread_mutex_lock(&preview.mutex);
preview.active = 0;
sample_load_file(preview.sample, name, samplerate,
raw_samplerate,
raw_channels,
sndfile_format);
sndfile_format,
resample_sndfile);
preview.next_frame = 0;
preview.active = 1;
pthread_mutex_unlock(&preview.mutex);
......
......@@ -48,7 +48,8 @@ void mixer_direct_control (int chan, int param, float value, Tick tick);
void mixer_preview (char* name,
/* zero for non-raw data */ int raw_samplerate,
/* zero for non-raw data */ int raw_channels,
/* zero for non-raw data */ int sndfile_format);
/* zero for non-raw data */ int sndfile_format,
int resample_sndfile);
int mixer_set_amplitude (float amplitude);
float mixer_get_amplitude (void);
......
......@@ -287,8 +287,6 @@ void patch_copy(Patch* dest, Patch* src)
{
int i;
dest->active = false;
sample_deep_copy(dest->sample, src->sample);
strcpy(dest->name, src->name);
......@@ -336,5 +334,5 @@ void patch_copy(Patch* dest, Patch* src)
for (i = 0; i < VOICE_MAX_ENVS; ++i)
dest->env_params[i] = src->env_params[i];
debug("copied patch src %p to patch dest %p\n", src, dest);
}
......@@ -89,6 +89,31 @@ void patch_trigger_global_lfos ( )
}
void patch_do_display_index(int id)
{
int i;
debug("calculating display index for patch id:%d\n", id);
assert(patches[id]->display_index == -1);
for (i = 0; i < PATCH_COUNT; i++)
{
if (i == id)
continue;
if (patches[i] && patches[i]->active
&& patches[i]->display_index >= patches[id]->display_index)
{
patches[id]->display_index = patches[i]->display_index + 1;
}
}
if (patches[id]->display_index == -1)
patches[id]->display_index = 0;
debug("chosen display: %d\n", patches[id]->display_index);
}
/**************************************************************************/
/********************** UTILITY FUNCTIONS *********************************/
......@@ -109,16 +134,18 @@ int patch_count()
int patch_create(void)
{
int id;
Patch* p;
int id;
/* find unoccupied patch id */
/* find first unused patch */
for (id = 0; patches[id] && patches[id]->active; ++id)
{
if (id == PATCH_COUNT)
{
pf_error(PF_ERR_PATCH_COUNT);
return -1;
}
}
if (!(p = patch_new()))
{
......@@ -126,9 +153,34 @@ int patch_create(void)
return -1;
}
debug("creating patch id:%d (%p)\n", id, p);
patches[id] = p;
patch_lock(id);
p->active = true;
patch_do_display_index(id);
patch_unlock(id);
return id;
}
int patch_duplicate(int src_id)
{
Patch* p;
int id;
assert(patchok(src_id));
assert(patches[src_id]->active);
debug("\n\nDuplicating patch %s id:%d...\n",
patches[src_id]->name, src_id);
if ((id = patch_create()) < 0)
return -1;
patch_lock(id);
patch_copy(patches[id], patches[src_id]);
patch_unlock(id);
return id;
......@@ -337,47 +389,6 @@ int patch_dump(int **dump)
return count;
}
int patch_duplicate(int src_id)
{
int i;
int dest_id;
assert(patchok(src_id));
assert(patches[src_id]->active);
dest_id = patch_create();
if (dest_id < 0)
return -1;
debug("Creating patch (%d) from patch %s (%d).\n", dest_id,
patches[src_id]->name, src_id);
patch_lock(dest_id);
patch_copy(patches[dest_id], patches[src_id]);
patches[dest_id]->display_index = 0;
for (i = 0; i < PATCH_COUNT; i++)
{
if (i == dest_id)
continue;
if (patches[i] && patches[i]->active
&& patches[i]->display_index >= patches[dest_id]->display_index)
{
patches[dest_id]->display_index = patches[i]->display_index + 1;
}
}
debug("chosen display: %d\n", patches[dest_id]->display_index);
patch_unlock(dest_id);
return dest_id;
}
/* stop all currently playing voices in given patch */
int patch_flush (int id)
......@@ -450,7 +461,8 @@ int patch_sample_load(int id, const char *name,
patch_samplerate,
raw_samplerate,
raw_channels,
sndfile_format);
sndfile_format,
1);
if (val < 0)
frames = 0;
......@@ -517,7 +529,8 @@ int patch_sample_load_from(int dest_id, int src_id)
name, patch_samplerate,
patches[src_id]->sample->raw_samplerate,
patches[src_id]->sample->raw_channels,
patches[src_id]->sample->sndfile_format);
patches[src_id]->sample->sndfile_format,
1);
/*
patches[dest_id].sample_stop = patches[dest_id].sample->frames - 1;
patches[dest_id].play_start = patches[src_id].play_start;
......@@ -644,3 +657,26 @@ void patch_sync (float bpm)
}
#if DEBUG
void patch_summary_dump(void)
{
int i;
debug("Patch summary\n");
debug("-------------\n");
for (i = 0; i < PATCH_COUNT; ++i)
{
Patch* p = patches[i];
if (p)
{
debug("patch (%p), id:%d '%s' display index:%d active:%s\n",
p, i, p->name, p->display_index,
(p->active) ? "Y" : "N");
}
}
debug("End of patch summary\n");
debug("--------------------\n");
}
#endif
......@@ -35,6 +35,7 @@ enum { USER_PATCH, DEFAULT_PATCH };
/* utility functions */
int patch_create (void);
int patch_duplicate (int id);
int patch_create_default (void);
void patch_destroy (int id);
......@@ -42,7 +43,6 @@ void patch_destroy_all (void);
int patch_count (void);
int patch_dump (int** dump);
int patch_duplicate (int id);
int patch_flush (int id);
void patch_flush_all (void);
const char* patch_strerror (int error);
......@@ -68,4 +68,9 @@ void patch_sync (float bpm);
int patch_verify (int id);
#if DEBUG
/* dump (to stdout) names, id's, display_indexes of all patches */
void patch_summary_dump(void);
#endif
#endif /* __PATCH_UTIL_H__ */
......@@ -325,7 +325,8 @@ int sample_load_file(Sample* sample, const char* name,
int rate,
int raw_samplerate,
int raw_channels,
int sndfile_format)
int sndfile_format,
int resample_sndfile)
{
float* tmp;
SF_INFO sfinfo;
......@@ -356,20 +357,22 @@ int sample_load_file(Sample* sample, const char* name,
sample->sndfile_format = 0;
}
if (sfinfo.samplerate != rate)
{
float* tmp2 = resample(tmp, rate, &sfinfo);
if (!tmp2)
{
free(tmp);
return -1;
}
free(tmp);
tmp = tmp2;
}
if (resample_sndfile) {
if (sfinfo.samplerate != rate)
{
float* tmp2 = resample(tmp, rate, &sfinfo);
if (!tmp2)
{
free(tmp);
return -1;
}
free(tmp);
tmp = tmp2;
}
}
if (sfinfo.channels == 1)
{
float* tmp2 = mono_to_stereo(tmp, &sfinfo);
......
......@@ -80,7 +80,8 @@ int sample_get_resampled_size(const char* name, int rate,
int sample_load_file(Sample*, const char* name, int rate,
/* zero for non-raw data */ int raw_samplerate,
/* zero for non-raw data */ int raw_channels,
/* zero for non-raw data */ int sndfile_format);
/* zero for non-raw data */ int sndfile_format,
int resample_sndfile);
void sample_free_data(Sample*); /* free's samples and filename */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment