void open_soundspec(void) { int scr; XGCValues gcv; if(disp != NULL) { XMapWindow(disp, win); XSync(disp, False); view_soundspec_flag = 1; return; } if((disp = XOpenDisplay(NULL)) == NULL) { ctl->cmsg(CMSG_FATAL, VERB_NORMAL, "Can't open display"); ctl->close(); exit(1); } set_color_ring(); scr = DefaultScreen(disp); depth = DefaultDepth(disp, scr); win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT, 0, 0, BlackPixel(disp, scr)); wm_delete_window = XInternAtom(disp, "WM_DELETE_WINDOW", False); XSetWMProtocols(disp, win, &wm_delete_window, 1); XSelectInput(disp, win, ExposureMask | KeyPressMask); XStoreName(disp, win, "Sound Spectrogram"); XSetIconName(disp, win, "Sound Spectrogram"); gcv.graphics_exposures = False; gc = XCreateGC(disp, win, GCGraphicsExposures, &gcv); offscr = XCreatePixmap(disp, win, SCOPE_WIDTH, SCOPE_HEIGHT, depth); XSetForeground(disp, gc, BlackPixel(disp, scr)); XFillRectangle(disp, offscr, gc, 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT); img = XCreateImage(disp, DefaultVisual(disp, scr), depth, ZPixmap, 0, 0, 1, SCOPE_HEIGHT, 8, 0); XMapWindow(disp, win); XSync(disp, False); view_soundspec_flag = 1; }
void open_soundspec(void) { static int initflag = 0; if( win.show){ ShowWindow(win.ref); } if(disp != NULL) { //already opened ring_index = 0; next_wakeup_samples = outcnt; memset(ring_buffer, 0, ring_buffer_len * sizeof(int32)); view_soundspec_flag = 1; return; } if(soundspec_update_interval == 0) soundspec_update_interval = (int32)(DEFAULT_UPDATE * play_mode->rate); disp=true; if(!initflag) { ring_buffer = (long*)safe_malloc(ring_buffer_len * sizeof(int32)); realfft(NULL, FFTSIZE); initialize_exp_hz_table(DEFAULT_ZOOM); initflag = 1; } set_color_ring(); ring_index = 0; next_wakeup_samples = outcnt; memset(ring_buffer, 0, sizeof(int32)); view_soundspec_flag = 1; }