// Simpler version when using opengl void P2MUpdateSongPosCallBack(void){ bool setfirstpos=ATOMIC_GET(root->setfirstpos); NInt curr_block_num = ATOMIC_GET(root->curr_blocknum); struct Tracker_Windows *window=root->song->tracker_windows; struct WBlocks *wblock = ListFindElement1(&window->wblocks->l,curr_block_num); int old_curr_realline = wblock->curr_realline; int till_curr_realline = R_BOUNDARIES(0, ATOMIC_GET(wblock->till_curr_realline), wblock->num_reallines-1); // till_curr_realline can be set from any thread, at any time, to any value. if (!ATOMIC_GET(root->play_cursor_onoff)){ //printf("P2MUpdateSongPosCallBack: Setting to %d\n",till_curr_realline); wblock->curr_realline = till_curr_realline; wblock->top_realline += till_curr_realline - old_curr_realline; wblock->bot_realline += till_curr_realline - old_curr_realline; } if(pc->playtype==PLAYSONG) BS_SelectPlaylistPos(ATOMIC_GET2(root->curr_playlist)); if(window->curr_block!=curr_block_num){ //printf("Bef. w: %d, r: %d\n",window->curr_block,root->curr_block); if(setfirstpos){ wblock->curr_realline=0; SetWBlock_Top_And_Bot_Realline(window,wblock); GE_set_curr_realline(0); } SelectWBlock( window, wblock ); //printf("Aft. w: %d, r: %d\n",window->curr_block,root->curr_block); } // make sure "Rec" is updated { static struct Tracks *current_track = NULL; static bool current_track_recording = false; struct Tracks *track = wblock->wtrack->track; if (track != current_track || (current_track!=NULL && track->is_recording != current_track_recording)){ current_track = track; current_track_recording = current_track->is_recording; GL_create(window, wblock); } } //GE_set_curr_realline(wblock->curr_realline); // printf("till_curr_realline: %d\n",wblock->till_curr_realline); //ScrollEditorToRealLine(window,wblock,wblock->curr_realline); }
void PlaySongFromStart(struct Tracker_Windows *window){ PlayStopReally(false); BS_SelectPlaylistPos(0); debug("root->curr_block: %d\n",root->curr_block); root->setfirstpos=true; pc->seqtime=0; InitAllInstrumentsForPlaySongFromStart(); { Place place; PlaceSetFirstPos(&place); PlaySong(&place,0); } }
int radium_main(char *arg){ struct Tracker_Windows *window; #if 0 // Seems to be some kind of problem when running givertcap? Try to uncomment and // see if you can start radium without segfaulting. I can't. -Kjetil. system("/usr/bin/givertcap"); #endif x11_display=XOpenDisplay(NULL); if(x11_display==NULL){ fprintf(stderr, "Unable to open display \"%s\"\n",XDisplayName(NULL)); return 1; } XSetIOErrorHandler (MySysErrorHandler); x11_screen=DefaultScreen(x11_display); printf("arg: -%s-\n",arg); printf("Width/Height: %d/%d\n",DisplayWidth(x11_display,x11_screen),DisplayHeight(x11_display,x11_screen)); X11_init_keyboard(); X11_StartBlockSelector(); X11_StartMidiProperties(); StartGuiThread(); posix_InitPlayer(); if(InitProgram()==true){ /* Here: More inits, receive events, other things. */ bool notend=true; printf("Inited\n"); XFlush(x11_display); // DrawUpTrackerWindow(root->song->tracker_windows); //XFlush(x11_display); window=root->song->tracker_windows; //GFX_StartFileRequester(); X11_StartQtStuff(); BS_UpdateBlockList(); BS_UpdatePlayList(); BS_SelectBlock(root->song->blocks); BS_SelectPlaylistPos(0); if(strlen(arg)>0) Load(arg); lockGUI(); while(notend==true){ int fd; fd_set fdset; XFlush(x11_display); fd=ConnectionNumber(x11_display); FD_ZERO(&fdset); FD_SET(fd,&fdset); unlockGUI(); while((fd=select(fd+1,&fdset,NULL,NULL,NULL)==-1)){ if(errno!=EINTR) break; } lockGUI(); while(XPending(x11_display)) { XEvent event; XNextEvent(x11_display, &event); //XNextEvent (x11_display, &event); window=root->song->tracker_windows; //P2MUpdateSongPosCallBack(); switch(event.type){ case KeyPress: if(X11_KeyPress((XKeyEvent *)&event,window)==1){ notend=false; } break; case KeyRelease: X11_KeyRelease((XKeyEvent *)&event,window); break; case ButtonPress: //printf("%d %d %d\n",((XButtonEvent *)&event)->x,((XButtonEvent *)&event)->y,((XButtonEvent *)&event)->button); switch(((XButtonEvent *)&event)->button){ case 1: tevent.ID=TR_LEFTMOUSEDOWN; break; case 2: tevent.ID=TR_MIDDLEMOUSEDOWN; break; case 3: tevent.ID=TR_RIGHTMOUSEDOWN; break; case 4: tevent.ID=TR_KEYBOARD; tevent.SubID=EVENT_UPARROW; break; case 5: tevent.ID=TR_KEYBOARD; tevent.SubID=EVENT_DOWNARROW; break; default: tevent.ID=TR_LEFTMOUSEDOWN; } tevent.x=((XButtonEvent *)&event)->x; tevent.y=((XButtonEvent *)&event)->y; EventReciever(&tevent,window); break; case ButtonRelease: //printf("%d %d %d\n",((XButtonEvent *)&event)->x,((XButtonEvent *)&event)->y,((XButtonEvent *)&event)->button); switch(((XButtonEvent *)&event)->button){ case 1: tevent.ID=TR_LEFTMOUSEUP; break; case 2: tevent.ID=TR_MIDDLEMOUSEUP; break; case 3: tevent.ID=TR_RIGHTMOUSEUP; break; default: tevent.ID=TR_LEFTMOUSEUP; } tevent.x=((XButtonEvent *)&event)->x; tevent.y=((XButtonEvent *)&event)->y; EventReciever(&tevent,window); break; case EnterNotify: case LeaveNotify: X11_ResetKeysUpDowns(); break; case MotionNotify: // printf("%d %d %d\n",((XMotionEvent *)&event)->x,((XMotionEvent *)&event)->y,((XMotionEvent *)&event)->state); tevent.ID=TR_MOUSEMOVE; tevent.x=((XButtonEvent *)&event)->x; tevent.y=((XButtonEvent *)&event)->y; EventReciever(&tevent,window); break; //case VisibilityNotify: // case ConfigureNotify: case ConfigureNotify: if( window->width!=((XConfigureEvent *)&event)->width || window->height!=((XConfigureEvent *)&event)->height ) { #if 0 fprintf(stderr,"Resized %d %d\n", ((XConfigureEvent *)&event)->width, ((XConfigureEvent *)&event)->height ); #endif XFreePixmap( x11_display, window->os_visual->pixmap ); XFreePixmap( x11_display, window->os_visual->cursorpixmap ); window->os_visual->pixmap=XCreatePixmap(x11_display, window->os_visual->window, ((XConfigureEvent *)&event)->width, ((XConfigureEvent *)&event)->height, (unsigned int)(DefaultDepth(x11_display,x11_screen)) ); XFillRectangle( x11_display, window->os_visual->pixmap, window->os_visual->gcs[0], 0, 0, ((XConfigureEvent *)&event)->width,((XConfigureEvent *)&event)->height ); window->os_visual->cursorpixmap=XCreatePixmap(x11_display, window->os_visual->window, ((XConfigureEvent *)&event)->width, ((XConfigureEvent *)&event)->height, (unsigned int)(DefaultDepth(x11_display,x11_screen)) ); XFillRectangle( x11_display, window->os_visual->cursorpixmap, window->os_visual->gcs[0], 0, 0, ((XConfigureEvent *)&event)->width, ((XConfigureEvent *)&event)->height ); Resize_resized( window, ((XConfigureEvent *)&event)->width-1, ((XConfigureEvent *)&event)->height-1, true ); } break; case Expose: printf("Expose\n"); //GFX_FilledBox(window,0,0,0,window->width,window->height); //DrawUpTrackerWindow(root->song->tracker_windows); Resize_resized(window,window->width,window->height,false); //XFlush(x11_display); break; case NoExpose: break; case GraphicsExpose: printf("GRaphicsExpose event.\n"); break; case ClientMessage: X11Event_ClientMessage((XClientMessageEvent *)&event,window); // printf("Received \"%s\"\n",((XClientMessageEvent *)&event)->data.b); break; default: printf("Unknown xevent %d\n",event.type); break; } } } EndProgram(); } posix_EndPlayer(); unlockGUI(); EndGuiThread(); XCloseDisplay(x11_display); return 0; }
void P2MUpdateSongPosCallBack(void){ struct Tracker_Windows *window=root->song->tracker_windows; bool setfirstpos=ATOMIC_GET(root->setfirstpos); NInt curr_block=ATOMIC_GET(root->curr_blocknum); struct WBlocks *wblock; int till_curr_realline; if(scrolls_per_second==-1) scrolls_per_second = SETTINGS_read_int("scrolls_per_second", default_scrolls_per_second); if(pc->playtype==PLAYSONG) BS_SelectPlaylistPos(root->curr_playlist); while(window!=NULL){ if(window->playalong==true){ DO_GFX({ wblock=ListFindElement1(&window->wblocks->l,curr_blocknum); till_curr_realline=ATOMIC_GET(wblock->till_curr_realline); if(window->curr_block!=curr_block){ if(setfirstpos){ wblock->curr_realline=0; SetWBlock_Top_And_Bot_Realline(window,wblock); } SelectWBlock( window, wblock ); } if(setfirstpos){ // The player routine (PEQblock.c) sets this one. ATOMIC_SET(wblock->till_curr_realline, 0); till_curr_realline=0; } //fprintf(stderr,"tilline: %d\n",till_curr_realline); #if 0 if(wblock->curr_realline != till_curr_realline) ScrollEditorToRealLine(window,wblock,till_curr_realline); #else { bool do_scrolling = false; if(wblock != last_wblock) do_scrolling = true; else if (last_time > ATOMIC_GET(pc->therealtime)) do_scrolling = true; else if(till_curr_realline < wblock->curr_realline) do_scrolling = true; else if(till_curr_realline > wblock->curr_realline){ STime from_time = (STime) ((double)Place2STime(wblock->block, &wblock->reallines[wblock->curr_realline]->l.p) / wblock->block->reltempo); STime to_time = (STime) ((double)Place2STime(wblock->block, &wblock->reallines[till_curr_realline]->l.p) / wblock->block->reltempo); STime time = to_time - from_time; STime time_necessary_to_scroll = pc->pfreq / scrolls_per_second; if(time>=time_necessary_to_scroll) do_scrolling = true; } if(do_scrolling==true) { ScrollEditorToRealLine(window,wblock,till_curr_realline); last_time = ATOMIC_GET(pc->therealtime); last_wblock = wblock; } } #endif }); }