From: Joe N. <nav...@um...> - 2000-04-09 21:56:50
|
Okay, I've checked in my initial attempt at a GtkWaveDraw widget. It's like 5 o'clockish on Sunday, and I'm going to a concert in about an hour, but I wanted to make sure I made this available. Notes first, then usage: - It's been checked into the glame/src/gui directory, but - I didn't put it in the makefile yet, for the simple reason that: - I didn't put any instances of it in the gui code yet. XWolf, I didn't want to start messing with your code, and I didn't dig into the swapfile API yet either, so it's still extremely independent of GLAME in general. Sorry 'bout that. A few parts of it I already know need to be cleaned up: - The widget doesn't resize properly right now. It's stuck at 600 x 200. I boofed the configure event assignment, but I'm not completely sure how yet. This is probably #1 on my list to fix right now. - The draw code is fairly quick, but it's *ugly*. I'll be making it a bit more elegant soon. - The color code is currently located inside the draw code. That design is terrible; I'll be splitting it out RSN, and adding functionality to change the default colors shortly after that. - A few other basic elements of the widget don't have helper functions yet (like the n_points_per_pixel elt, which should *definitely* have an assignment wrapper, which means the widget doesn't look quite right yet). Of course, since this is an initial hack, it hasn't been fully tested, but I've tried to test it almost to my satisfaction. Okay. Basic usage is as follows: - Standard creation. GtkWaveDraw *wavedraw = gtk_wave_draw_new(); - Set the range of samples you want to be displayed gtk_wave_draw_zoom(GTK_WAVE_DRAW(wavedraw), first_sample, last_sample); (Typically, I figure first_sample will be = 0, and last_sample is going to be = num_samples_in_this_wave). - Add any number of waves gtk_wave_draw_add_wave(GTK_WAVE_DRAW(wavedraw), float_array, number_of_points_in_the_array, start_offset_from_sample_zero); The amount you can add is fairly large (I didn't test any upper limits, but variable keeping track of the number of waves in the widget is a gint), but since each wave you add caches a copy of the float array in the widget, it's gonna be a memory hog if you have long, high-resolution, multi-channel samples. This could potentially be a problem. It is assumed that the floats will all be in the range [-1,1]. This is a fairly huge assumption; if those values are wrong or might change under different circumstances, I'll fix the code. The reason I added an offset parameter is so that you can do before-and-after viewing of small subsections of the wave -- if you're fading out the last five seconds of a ten-second piece, your offset for the "after" wave would be somewhere around 220500, etc. - Standard drawing Generating an expose event will cause the widget to (if necessary) redraw itself to the backbuffer and then copy itself to the front buffer. I think I left the _draw() call (gtk_wave_draw_draw, stupid name) static to the widget, however, so firing an expose is right now the easiest way to get the widget to update. This'll probably change. I'm going to keep working on it later tonight (after the show), but I plan on limiting myself (for now) to just working on the widget, and not integrating it with the main GUI yet. -Joe |