int main (int argc, char* argv[]) { if(sizeof(off_t) != 8){ gerr("sizeof(off_t)=%zu\n", sizeof(off_t)); return EXIT_FAILURE; } set_log_handlers(); wf_debug = 0; gtk_init(&argc, &argv); GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); #if 0 agl_get_instance()->pref_use_shaders = false; #endif WaveformView* waveform = waveform_view_new(NULL); #if 0 waveform_view_set_show_rms(waveform, false); waveform_view_add_layer(waveform, grid_actor(waveform_view_get_actor(waveform)), 0); #endif gtk_widget_set_size_request((GtkWidget*)waveform, 512, 256); gtk_container_add((GtkContainer*)window, (GtkWidget*)waveform); gtk_widget_show_all(window); char* filename = find_wav(WAV); waveform_view_load_file(waveform, filename); g_free(filename); add_key_handlers((GtkWindow*)window, waveform, (Key*)&keys); gboolean window_on_delete(GtkWidget* widget, GdkEvent* event, gpointer user_data){ gtk_main_quit(); return false; }
int main (int argc, char* argv[]) { if(sizeof(off_t) != 8){ gerr("sizeof(off_t)=%zu\n", sizeof(off_t)); return EXIT_FAILURE; } set_log_handlers(); gtk_init(&argc, &argv); GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); static GtkWidget* box; box = gtk_vbox_new(FALSE, 4); gtk_container_add((GtkContainer*)window, box); WaveformView* waveform[2] = {waveform_view_new(NULL),}; waveform_view_set_show_rms(waveform[0], false); gtk_box_pack_start((GtkBox*)box, (GtkWidget*)waveform[0], TRUE, TRUE, 0); gtk_widget_show_all(window); //#define WAV "test/data/mono_0:10.wav" #define WAV "test/data/stereo_1.wav" char* filename = g_build_filename(g_get_current_dir(), WAV, NULL); waveform_view_load_file(waveform[0], filename); g_free(filename); gboolean key_press(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { WaveformView** waveform = user_data; switch(event->keyval){ case 61: waveform_view_set_zoom(waveform[0], waveform[0]->zoom * 1.5); break; case 45: waveform_view_set_zoom(waveform[0], waveform[0]->zoom / 1.5); break; case KEY_Left: case KEY_KP_Left: dbg(0, "left"); waveform_view_set_start(waveform[0], waveform[0]->start_frame - 8192 / waveform[0]->zoom); break; case KEY_Right: case KEY_KP_Right: dbg(0, "right"); waveform_view_set_start(waveform[0], waveform[0]->start_frame + 8192 / waveform[0]->zoom); break; case GDK_KEY_2: if(!waveform[1]){ // TODO fix issues with 2 widgets sharing the same drawable ? gtk_box_pack_start((GtkBox*)box, (GtkWidget*)(waveform[1] = waveform_view_new(NULL)), TRUE, TRUE, 0); char* filename = g_build_filename(g_get_current_dir(), WAV, NULL); waveform_view_load_file(waveform[1], filename); g_free(filename); gtk_widget_show((GtkWidget*)waveform[1]); } dbg(0, "2"); break; case GDK_KP_Enter: break; case 113: exit(EXIT_SUCCESS); break; case GDK_Delete: break; default: dbg(0, "%i", event->keyval); break; } return TRUE; }
int main (int argc, char *argv[]) { if(sizeof(off_t) != 8){ gerr("sizeof(off_t)=%zu\n", sizeof(off_t)); return EXIT_FAILURE; } set_log_handlers(); wf_debug = 1; gtk_init(&argc, &argv); GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); WaveformView* waveform = waveform_view_new(NULL); waveform_view_set_show_rms(waveform, false); #if 0 waveform_view_set_show_grid(waveform, true); #endif gtk_container_add((GtkContainer*)window, (GtkWidget*)waveform); gtk_widget_show_all(window); char* filename = find_wav(); waveform_view_load_file(waveform, filename); g_free(filename); gboolean key_press(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { WaveformView* waveform = user_data; int n_visible_frames = ((float)waveform->waveform->n_frames) / waveform->zoom; switch(event->keyval){ case 61: waveform_view_set_zoom(waveform, waveform->zoom * 1.5); break; case 45: waveform_view_set_zoom(waveform, waveform->zoom / 1.5); break; case KEY_Left: case KEY_KP_Left: dbg(1, "left"); waveform_view_set_start(waveform, waveform->start_frame - n_visible_frames / 10); break; case KEY_Right: case KEY_KP_Right: dbg(1, "right"); waveform_view_set_start(waveform, waveform->start_frame + n_visible_frames / 10); break; case GDK_KP_Enter: break; case (char)'<': break; case '>': break; case 113: exit(EXIT_SUCCESS); break; case GDK_Delete: break; default: dbg(1, "%i", event->keyval); break; } return TRUE; }