void next_wav(C* c) { if(wi >= G_N_ELEMENTS(wavs)){ if(iter++ < 2){ wi = 0; }else{ g_free(c); FINISH_TEST; } } dbg(0, "=========================================================="); reset_timeout(40000); Waveform* w = waveform_new(wavs[wi++]); g_object_weak_ref((GObject*)w, finalize_notify, NULL); waveform_load_sync(w); #if 0 // due to internal changes, these tests are no longer valid WfGlBlock* blocks = (WfGlBlock*)w->priv->render_data[MODE_MED]; assert(blocks, "texture container not allocated"); assert(!blocks->peak_texture[WF_LEFT].main[0], "textures allocated"); // no textures are expected to be allocated. assert(!blocks->peak_texture[WF_RIGHT].main[0], "textures allocated"); #endif assert(&w->priv->peak, "peak not loaded"); assert(w->priv->peak.size, "peak size not set"); assert(w->priv->peak.buf[WF_LEFT], "peak not loaded"); assert(w->priv->peak.buf[WF_RIGHT], "peak not loaded"); g_object_unref(w); c->next(c); }
void test_peakgen() { START_TEST; if(!wf_peakgen__sync(WAV, WAV ".peak")){ FAIL_TEST("local peakgen failed"); } //create peakfile in the cache directory Waveform* w = waveform_new(WAV); char* p = waveform_ensure_peakfile__sync(w); assert(p, "cache dir peakgen failed"); FINISH_TEST; }
void test_peakgen() { START_TEST; char* filename = find_wav(WAV); assert(filename, "cannot find file %s", WAV); if(!wf_peakgen__sync(filename, WAV ".peak", NULL)){ FAIL_TEST("local peakgen failed"); } // create peakfile in the cache directory Waveform* w = waveform_new(filename); g_free(filename); char* p = waveform_ensure_peakfile__sync(w); assert(p, "cache dir peakgen failed"); FINISH_TEST; }
GError* error = NULL; a = wf_peakgen__sync("bad.wav", "bad.peak", &error); assert(error, "expected error"); g_error_free(error); void callback(Waveform* w, GError* error, gpointer _c) { PF0; WfTest* c = _c; assert(error, "GError not set") WF_TEST_FINISH; } Waveform* w = waveform_new(NULL); waveform_set_file(w, "bad.wav"); waveform_load(w, callback, WF_NEW(C1, .test = { .test_idx = current_test, } ) ); } /* * Test reading of audio files. */ void
void sample_editor_init(GtkWidget * parent) { GtkWindow* w; GtkWidget* master_vbox; GtkWidget* hbox; GtkWidget* brow; GtkWidget* button; GtkWidget* image; GtkWidget* label; GtkWidget* tmp; assert(se == 0); se = sample_editor_private_new(); /* main window */ se->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); w = GTK_WINDOW(se->window); gtk_window_set_title(w, "Edit Sample"); gtk_window_set_resizable(w, TRUE); gtk_window_set_transient_for(w, GTK_WINDOW(parent)); gtk_window_set_modal(w, FALSE); g_signal_connect(G_OBJECT(w), "delete-event", G_CALLBACK(cb_close), NULL); /* master vbox */ master_vbox = gtk_vbox_new(FALSE, GUI_SPACING); gtk_container_add(GTK_CONTAINER(se->window), master_vbox); gtk_container_set_border_width(GTK_CONTAINER(se->window), GUI_SPACING); gtk_widget_show(master_vbox); /* top row hbox */ se->toolbar1 = hbox = gtk_hbox_new(FALSE, GUI_SPACING); gtk_box_pack_start(GTK_BOX(master_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); /* play button */ image = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), image); gtk_box_pack_start(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK(cb_play), NULL); gtk_widget_show(image); gtk_widget_show(button); /* stop button */ image = gtk_image_new_from_stock(GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new ( ); gtk_container_add (GTK_CONTAINER (button), image); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (cb_stop), NULL); gtk_widget_show(image); gtk_widget_show(button); /* separator */ tmp = gtk_vseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), tmp, FALSE, FALSE, 0); gtk_widget_show(tmp); /* fade spin button */ label = gtk_label_new("Fade:"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); se->fade_spin = gtk_spin_button_new_with_range(0, 1, 1); gtk_box_pack_start(GTK_BOX(hbox), se->fade_spin, FALSE, FALSE, 0); gtk_widget_show(se->fade_spin); g_signal_connect(G_OBJECT(se->fade_spin), "value-changed", G_CALLBACK(cb_fade_spin_changed), NULL); /* X-fade spin button */ label = gtk_label_new("X-Fade:"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); se->xfade_spin = gtk_spin_button_new_with_range(0, 1, 1); gtk_box_pack_start(GTK_BOX(hbox), se->xfade_spin, FALSE, FALSE, 0); gtk_widget_show(se->xfade_spin); g_signal_connect(G_OBJECT(se->xfade_spin), "value-changed", G_CALLBACK(cb_xfade_spin_changed), NULL); /* separator */ tmp = gtk_vseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), tmp, FALSE, FALSE, 0); gtk_widget_show(tmp); /* mark combo */ se->mark_combo = basic_combo_create(waveform_get_mark_names()); gtk_box_pack_start(GTK_BOX(hbox), se->mark_combo, FALSE, FALSE, 0); gtk_widget_show(se->mark_combo); g_signal_connect(G_OBJECT(se->mark_combo), "changed", G_CALLBACK(cb_mark_combo_changed), NULL); se->mark_spin = gtk_spin_button_new_with_range(0, 1, 1); gtk_box_pack_start(GTK_BOX(hbox), se->mark_spin, FALSE, FALSE, 0); gtk_widget_show(se->mark_spin); g_signal_connect(G_OBJECT(se->mark_spin), "value-changed", G_CALLBACK(cb_mark_spin_changed), NULL); /* mark spin value label */ se->mark_val = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(hbox), se->mark_val, FALSE, FALSE, 0); gtk_widget_show(se->mark_val); /* separator */ tmp = gtk_vseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), tmp, FALSE, FALSE, 0); gtk_widget_show(tmp); /* loop points clear button */ button = gtk_button_new_with_label ("Loop"); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (cb_clear), (gpointer) "loop"); gtk_widget_show (button); /* play points clear button */ button = gtk_button_new_with_label ("Play"); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (cb_clear), (gpointer) "play"); gtk_widget_show (button); /* clear label */ label = gtk_label_new ("Clear Points:"); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); /* waveform */ se->waveform = waveform_new(); waveform_set_patch( WAVEFORM(se->waveform), -1); waveform_set_size( WAVEFORM(se->waveform), 512, 256); waveform_set_interactive( WAVEFORM(se->waveform), TRUE); gtk_box_pack_start(GTK_BOX(master_vbox), se->waveform, TRUE, TRUE, 0); gtk_widget_show(se->waveform); g_signal_connect(G_OBJECT(se->waveform), "play-changed", G_CALLBACK(cb_wf_play_changed), NULL); g_signal_connect(G_OBJECT(se->waveform), "loop-changed", G_CALLBACK(cb_wf_loop_changed), NULL); g_signal_connect(G_OBJECT(se->waveform), "mark-changed", G_CALLBACK(cb_wf_mark_changed), NULL); g_signal_connect(G_OBJECT(se->waveform), "view-changed", G_CALLBACK(cb_wf_view_changed), NULL); /* waveform scrollbar */ se->hscrolladj = gtk_adjustment_new(0.0, 0.0, 1.0, 0.0, 0.0, 1.0); se->hscroll = gtk_hscrollbar_new(GTK_ADJUSTMENT(se->hscrolladj)); gtk_box_pack_start(GTK_BOX(master_vbox), se->hscroll, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(se->hscroll), "value-changed", G_CALLBACK (cb_scroll), NULL); gtk_widget_show (se->hscroll); /* bottom row hbox */ brow = gtk_hbox_new(FALSE, 0); gtk_box_pack_start (GTK_BOX(master_vbox), brow, FALSE, FALSE, 0); gtk_widget_show(brow); se->toolbar2 = hbox = gtk_hbox_new (FALSE, GUI_SPACING); gtk_box_pack_start (GTK_BOX(brow), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* zoom-out button */ image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), image); gtk_box_pack_start(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK(cb_zoom_out), NULL); gtk_widget_show(image); gtk_widget_show(button); /* zoom-in button */ image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), image); gtk_box_pack_start(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK(cb_zoom_in), NULL); gtk_widget_show(image); gtk_widget_show(button); /* zoom-1:1 button */ image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_100, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), image); gtk_box_pack_start(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK(cb_zoom_1to1), NULL); gtk_widget_show(image); gtk_widget_show(button); /* zoom-all button */ image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_FIT, GTK_ICON_SIZE_SMALL_TOOLBAR); button = gtk_button_new(); gtk_container_add(GTK_CONTAINER(button), image); gtk_box_pack_start(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK(cb_zoom_all), NULL); gtk_widget_show(image); gtk_widget_show(button); hbox = gtk_hbox_new (FALSE, GUI_SPACING); gtk_box_pack_end(GTK_BOX(brow), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* close button */ button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(cb_close), NULL); gtk_widget_show (button); /* reset button */ se->reset = button = gtk_button_new_with_label ("Reset"); gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(cb_reset), NULL); gtk_widget_show (button); }