static void draw_scope(double *values) { static int32 call_cnt; int offset, expose,i; RGBColor pixels[SCOPE_HEIGHT]; double work[SCOPE_HEIGHT]; int nze; Rect righthalf={0,SCOPE_WIDTH - SCROLL_THRESHOLD, SCOPE_HEIGHT, SCOPE_WIDTH }, lefthalf={0,0, SCOPE_HEIGHT, SCOPE_WIDTH - SCROLL_THRESHOLD-1 }; nze = 0; make_logspectrogram(values, work); if( win.show ){ set_draw_pixel(work, pixels); expose = 0; SetPortWindowPort(win.ref); offset = call_cnt % SCROLL_THRESHOLD; if(offset == 0) { //scroll the window EraseRect(&lefthalf); ScrollRect(&win.ref->portRect, -(SCOPE_WIDTH - SCROLL_THRESHOLD), 0, 0); EraseRect(&righthalf); } //draw for( i=0; i<SCOPE_HEIGHT; i++ ){ RGBForeColor(&pixels[i]); MoveTo(SCOPE_WIDTH - SCROLL_THRESHOLD + offset,i); Line(0,0); } } if( skin_need_speana ){ skin_draw_spectrum(work); //ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "." ); } if(nze) initialize_exp_hz_table(soundspec_zoom - 4 * nze); call_cnt++; }
static void draw_scope(double *values) { static int32 call_cnt; int offset, expose; XEvent e; char pixels[SCOPE_HEIGHT*32]; double work[SCOPE_HEIGHT]; int nze; char *mname; KeySym k; make_logspectrogram(values, work); set_draw_pixel(work, pixels); expose = 0; nze = 0; while(QLength(disp) || XPending(disp)) { XNextEvent(disp, &e); switch(e.type) { case Expose: expose++; break; case KeyPress: k = xlookup_key(&e.xkey); switch(k) { #ifdef XK_Down case XK_Up: #endif /* XK_Up */ #ifdef XK_KP_Up case XK_KP_Up: #endif /* XK_KP_Up */ nze++; break; #ifdef XK_Down case XK_Down: #endif /* XK_Down */ #ifdef XK_KP_Down case XK_KP_Down: #endif /* XK_KP_Down */ nze--; break; #ifdef XK_Left case XK_Left: #endif /* XK_Left */ #ifdef XK_KP_Left case XK_KP_Left: #endif /* XK_KP_Left */ soundspec_update_interval = (int32)(soundspec_update_interval*1.1); break; #ifdef XK_Right case XK_Right: #endif /* XK_Right */ #ifdef XK_KP_Right case XK_KP_Right: #endif /* XK_KP_Right */ soundspec_update_interval = (int32)(soundspec_update_interval/1.1); if(soundspec_update_interval < 0.01 * play_mode->rate) soundspec_update_interval = (int32)(0.01 * play_mode->rate); break; } break; case ClientMessage: if(wm_delete_window == e.xclient.data.l[0]) { mname = XGetAtomName(disp, e.xclient.message_type); if(mname != NULL && strcmp(mname, "WM_PROTOCOLS") == 0) { /* Delete message from WM */ ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "Sound Spectrogram Window is closed"); close_soundspec(); XCloseDisplay(disp); disp = NULL; return; } } break; } } offset = call_cnt % SCROLL_THRESHOLD; if(offset == 0) { XCopyArea(disp, offscr, offscr, gc, SCROLL_THRESHOLD, 0, SCOPE_WIDTH - SCROLL_THRESHOLD, SCOPE_HEIGHT, 0, 0); XSetForeground(disp, gc, BlackPixel(disp, DefaultScreen(disp))); XFillRectangle(disp, offscr, gc, SCOPE_WIDTH - SCROLL_THRESHOLD, 0, SCROLL_THRESHOLD, SCOPE_HEIGHT); XCopyArea(disp, offscr, win, gc, 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT, 0, 0); } img->data = (char *)pixels; XPutImage(disp, offscr, gc, img, 0, 0, SCOPE_WIDTH - SCROLL_THRESHOLD + offset, 0, 1, SCOPE_HEIGHT); if(!expose) XCopyArea(disp, offscr, win, gc, SCOPE_WIDTH - SCROLL_THRESHOLD + offset, 0, 1, SCOPE_HEIGHT, SCOPE_WIDTH - SCROLL_THRESHOLD + offset, 0); else { XCopyArea(disp, offscr, win, gc, 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT, 0, 0); } XSync(disp, False); if(nze) initialize_exp_hz_table(soundspec_zoom - 4 * nze); call_cnt++; }