T2_data *T3_maybe_get_t2_data(void){ if (ATOMIC_GET(g_use_t2_thread)==Use_T2_Thread::YES){ bool got_new_t2_data; T2_data *t2_data = t2_to_t3_queue.T2_tryGet(got_new_t2_data); if (!got_new_t2_data) return NULL; return t2_data; } else if (ATOMIC_GET(g_use_t2_thread)==Use_T2_Thread::NO){ bool got_new_t1_data; T1_data *t1_data = t1_to_t2_queue.tryGet(got_new_t1_data); if (!got_new_t1_data) return NULL; T2_data *t2_data = new T2_data(t1_data->painting_data, t1_data->background_color); GE_draw_vl(t2_data); delete t1_data; return t2_data; } else { return NULL; } }
void switchEditOnOff(void){ struct Tracker_Windows *window=getWindowFromNum(-1); ATOMIC_SET(root->editonoff, ATOMIC_GET(root->editonoff)?false:true); char temp[1000]; sprintf(temp,"Edit %s",ATOMIC_GET(root->editonoff)?"On":"Off"); GFX_SetStatusBar(temp); window->must_redraw=true; }
// 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); }
static void DrawAllWTrackNames( struct Tracker_Windows *window, const struct WBlocks *wblock ) { //int num_tracks = ListFindNumElements1(&wblock->wtracks->l); //bool *draw_border = alloca(sizeof(bool) * num_tracks); //memset(draw_border, 0, sizeof(bool) * num_tracks); { const struct WTracks *wtrack1 = get_leftmost_visible_wtrack(wblock); if (wtrack1==NULL) return; const struct WTracks *rightmost_wtrack = get_rightmost_visible_wtrack(wblock, wtrack1); R_ASSERT_RETURN_IF_FALSE(rightmost_wtrack!=NULL); int tracknum1 = wtrack1->l.num; int channelnum1 = ATOMIC_GET(wtrack1->track->midi_channel); struct Patch *patch1 = wtrack1->track->patch; struct WTracks *wtrack2 = NextWTrack(wtrack1); int tracknum2 = tracknum1; for(;;){ int channelnum2 = wtrack2==NULL ? 0 : ATOMIC_GET(wtrack2->track->midi_channel); if (wtrack2==NULL || wtrack2->track->patch==NULL || patch1==NULL || wtrack2->track->patch != patch1 || channelnum2 != channelnum1){ DrawWTrackNames(window, wblock, tracknum1, tracknum2); tracknum1 = tracknum2 = tracknum2+1; channelnum1 = channelnum2; patch1 = wtrack2==NULL ? NULL : wtrack2->track->patch; if (tracknum1 > rightmost_wtrack->l.num) break; } else { tracknum2++; } if (wtrack2==NULL) break; //if (tracknum2 - tracknum1 >= 1) // draw_border[wtrack2->l.num] = true; wtrack2 = NextWTrack(wtrack2); } } }
void EditorWidget::updateEditor(){ if(ATOMIC_GET(is_starting_up)==true) return; { struct Patch *patch = ATOMIC_GET(atomic_must_redraw_instrument); if (patch!=NULL){ ATOMIC_SET(atomic_must_redraw_instrument, NULL); GFX_update_instrument_widget(patch);//GFX_update_instrument_patch_gui(patch); } } transfer_atomic_must_redraws(window); #if 0 //!defined(RELEASE) { int queue_size = GFX_get_op_queue_size(this->window); if (queue_size > 0 || this->window->must_calculate_coordinates==true || this->window->must_redraw==true || this->window->must_redraw_editor) printf("..Updating. Queue: %d. Update coordinates: %d. Redraw editor: %d. Redraw: %d\n", queue_size, this->window->must_calculate_coordinates, this->window->must_redraw_editor, this->window->must_redraw ); } #endif if (GFX_get_op_queue_size(this->window)>0) this->window->must_redraw = true; if (this->window->must_calculate_coordinates==true){ this->window->must_redraw = true; this->window->must_calculate_coordinates=false; } if (this->window->must_redraw) { UpdateTrackerWindowCoordinates(window); UpdateWBlockCoordinates(this->window, this->window->wblock); GFX_UpdateUpperLeft(window, window->wblock); UpdateAllPianoRollHeaders(window, window->wblock); SEQUENCER_update(); update(); this->window->must_redraw_editor=true; this->window->must_redraw=false; } if (this->window->must_redraw_editor==true){ GL_create(this->window, this->window->wblock); if (!is_playing()) SEQUENCER_update(); this->window->must_redraw_editor=false; } }
static void Scroll_play_down3( struct WBlocks *wblock, const Place *p1, const Place *p2 ){ struct Tracks *track = wblock->block->tracks; while(track != NULL){ if (track->onoff==1){ struct Patch *patch=track->patch; if (patch != NULL){ struct Notes *note = track->notes; while(note != NULL){ if (PlaceIsBetween2(¬e->l.p, p1, p2)) PATCH_play_note(patch, create_note_t(NULL, note->id, note->note, VELOCITY_get(note->velocity), TRACK_get_pan(track), ATOMIC_GET(track->midi_channel), 0) ); if (PlaceIsBetween2(¬e->end, p1, p2)) PATCH_stop_note(patch, create_note_t(NULL, note->id, note->note, 0, TRACK_get_pan(track), ATOMIC_GET(track->midi_channel), 0 ) ); note = NextNote(note); } } } track = NextTrack(track); } }
static void *stats_thread(void *arg) { uint32_t seconds = 0; while (TRUE) { #ifndef DEBUG printf("%ds\tProcessed: %d\tConns: %d\tLogins: %d\tRan: %d\tEchoes:%d Wgets: %d, TFTPs: %d\n", seconds++, ATOMIC_GET(&srv->total_input), ATOMIC_GET(&srv->curr_open), ATOMIC_GET(&srv->total_logins), ATOMIC_GET(&srv->total_successes), ATOMIC_GET(&srv->total_echoes), ATOMIC_GET(&srv->total_wgets), ATOMIC_GET(&srv->total_tftps)); #endif fflush(stdout); sleep(1); } }
void EditorWidget::paintEvent( QPaintEvent *e ){ if(ATOMIC_GET(is_starting_up)==true) return; //static int n=0; printf("** Drawing up everything! %d\n",n++); GFX_clear_op_queue(this->window); g_allowed_to_grow_queue = true; DO_GFX(DrawUpTrackerWindow(this->window)); g_allowed_to_grow_queue = false; if(GFX_get_op_queue_size(this->window) > 0){ QPainter paint(this); this->painter = &paint; //this->painter->setFont(this->font); { GFX_play_op_queue(this->window); //GFX_clear_op_queue(this->window); } this->painter = NULL; } }
/* enqueue should be called by the relevant API function */ void *message_enqueue(CSOUND *csound, int32_t message, char *args, int argsiz) { if(csound->msg_queue != NULL) { int64_t *rtn; volatile long items; /* block if queue is full */ do { items = ATOMIC_GET(csound->msg_queue_items); } while(items >= API_MAX_QUEUE); message_queue_t* msg = csound->msg_queue[atomicGet_Incr_Mod(&csound->msg_queue_wget, API_MAX_QUEUE)]; msg->message = message; if(msg->args != NULL) csound->Free(csound, msg->args); msg->args = (char *)csound->Calloc(csound, argsiz); memcpy(msg->args, args, argsiz); rtn = &msg->rtn; csound->msg_queue[atomicGet_Incr_Mod(&csound->msg_queue_wput, API_MAX_QUEUE)] = msg; ATOMIC_INCR(csound->msg_queue_items); return (void *) rtn; } else return NULL; }
// Note that it's perfectly fine calling PlayStop() between calling PC_Pause and PC_StopPause. PC_StopPause will still work as it's supposed to. void PC_Pause(void){ R_ASSERT(THREADING_is_main_thread()); //printf(" 000 Enter pause %d\n", g_pausing_level); g_pausing_level++; //printf(" Enter pause %d\n", g_pausing_level); if (g_pausing_level > 1) return; g_was_playing = false; g_playtype = 0; g_was_playing_range = false; if (is_playing()){ if(ATOMIC_GET(is_starting_up)==false){ struct Tracker_Windows *window = root->song->tracker_windows; window->message = "Temporarily stopping player"; window->message_duration_left = 100; } g_playtype = pc->playtype; g_was_playing_range = pc->is_playing_range; PlayStop(); g_was_playing = true; } }
void BACKUP_call_very_often(void){ static bool has_inited = false; if (has_inited==false){ RT_BACKUP_reset_timer(); has_inited=true; } static bool is_playing = false; Player_State player_state = ATOMIC_GET(pc->player_state); if (!is_playing && player_state==PLAYER_STATE_PLAYING){ is_playing = true; g_curr_playing_start_time = TIME_get_ms(); } if (is_playing && player_state==PLAYER_STATE_STOPPED){ is_playing = false; double added_playing_duration = TIME_get_ms() - g_curr_playing_start_time; g_curr_playing_duration += added_playing_duration; } if (is_playing) return; //printf("duration: %f\n",get_unbackuped_duration() / 1000.0); if (get_unbackuped_duration() > get_backup_interval_ms()){ make_backup(); RT_BACKUP_reset_timer(); } }
void T1_ensure_t2_is_initialized(void){ if (ATOMIC_GET(g_use_t2_thread)==Use_T2_Thread::UNINITIALIZED){ if(SETTINGS_read_bool("opengl_draw_in_separate_process",true)) ATOMIC_SET(g_use_t2_thread, Use_T2_Thread::YES); else ATOMIC_SET(g_use_t2_thread, Use_T2_Thread::NO); } }
double RT_LPB_get_current_BPM(const struct SeqTrack *seqtrack){ if (ATOMIC_GET(is_starting_up)) return 120.0; else if (is_playing()) return seqtrack->lpb_iterator.curr_bpm; else { struct Blocks *block = ATOMIC_GET(g_curr_block); if (block==NULL) return (double)root->tempo; else return (double)root->tempo * ATOMIC_DOUBLE_GET(block->reltempo); } }
static void GDKmemdump(void) { struct Mallinfo m = MT_mallinfo(); MEMDEBUG { THRprintf(GDKstdout, "\n#mallinfo.arena = " SSZFMT "\n", (ssize_t) m.arena); THRprintf(GDKstdout, "#mallinfo.ordblks = " SSZFMT "\n", (ssize_t) m.ordblks); THRprintf(GDKstdout, "#mallinfo.smblks = " SSZFMT "\n", (ssize_t) m.smblks); THRprintf(GDKstdout, "#mallinfo.hblkhd = " SSZFMT "\n", (ssize_t) m.hblkhd); THRprintf(GDKstdout, "#mallinfo.hblks = " SSZFMT "\n", (ssize_t) m.hblks); THRprintf(GDKstdout, "#mallinfo.usmblks = " SSZFMT "\n", (ssize_t) m.usmblks); THRprintf(GDKstdout, "#mallinfo.fsmblks = " SSZFMT "\n", (ssize_t) m.fsmblks); THRprintf(GDKstdout, "#mallinfo.uordblks = " SSZFMT "\n", (ssize_t) m.uordblks); THRprintf(GDKstdout, "#mallinfo.fordblks = " SSZFMT "\n", (ssize_t) m.fordblks); } #ifdef GDK_MEM_KEEPHISTO { int i; THRprintf(GDKstdout, "#memory histogram\n"); for (i = 3; i < GDK_HISTO_MAX_BIT - 1; i++) { size_t j = 1 << i; THRprintf(GDKstdout, "# " SZFMT " " SZFMT "\n", j, ATOMIC_GET(GDK_nmallocs[i], mbyteslock, "GDKmemdump")); } } #endif #ifdef GDK_VM_KEEPHISTO { int i; THRprintf(GDKstdout, "\n#virtual memory histogram\n"); for (i = 12; i < GDK_HISTO_MAX_BIT - 1; i++) { size_t j = 1 << i; THRprintf(GDKstdout, "# " SZFMT " " SZFMT "\n", j, ATOMIC_GET(GDK_vm_nallocs[i], mbyteslock, "GDKmemdump")); } } #endif }
static FlowEvent q_dequeue(Queue *q, Client cntxt) { FlowEvent r = NULL; assert(q); MT_sema_down(&q->s, "q_dequeue"); if (ATOMIC_GET(exiting, exitingLock, "q_dequeue")) return NULL; MT_lock_set(&q->l, "q_dequeue"); if (cntxt) { int i; for (i = q->last - 1; i >= 0; i--) { if (q->data[i]->flow->cntxt == cntxt) { r = q->data[i]; q->last--; while (i < q->last) { q->data[i] = q->data[i + 1]; i++; } break; } } MT_lock_unset(&q->l, "q_dequeue"); return r; } if (q->exitcount > 0) { q->exitcount--; MT_lock_unset(&q->l, "q_dequeue"); return NULL; } assert(q->last > 0); if (q->last > 0) { /* LIFO favors garbage collection */ r = q->data[--q->last]; q->data[q->last] = 0; } /* else: terminating */ /* try out random draw * { int i; i = rand() % q->last; r = q->data[i]; for (i++; i < q->last; i++) q->data[i - 1] = q->data[i]; q->last--; i } */ MT_lock_unset(&q->l, "q_dequeue"); assert(r); return r; }
static void transfer_atomic_must_redraws(struct Tracker_Windows *window) { bool a_must_redraw = ATOMIC_GET(atomic_must_redraw); if (a_must_redraw){ ATOMIC_SET(atomic_must_redraw, false); window->must_redraw = true; } bool a_must_redraw_editor = ATOMIC_GET(atomic_must_redraw_editor); if (a_must_redraw_editor){ ATOMIC_SET(atomic_must_redraw_editor, false); window->must_redraw_editor = true; } bool a_must_calculate = ATOMIC_GET(atomic_must_calculate_coordinates); if (a_must_calculate){ ATOMIC_SET(atomic_must_calculate_coordinates, false); window->must_calculate_coordinates = true; } }
void polyKeyDownPlay(int notenum,int windownum){ struct Tracker_Windows *window=getWindowFromNum(windownum); notenum+=root->keyoct; if(notenum<=0 || notenum>127) return; if(window==NULL || window->curr_track<0) return; PATCH_playNoteCurrPos(window,notenum,-1); if(ATOMIC_GET(root->editonoff)) InsertNoteCurrPos(window,notenum,true,-1); }
void EditorWidget::wheelEvent(QWheelEvent *qwheelevent){ if(ATOMIC_GET(is_starting_up)==true) return; if (MIXER_is_saving()) return; struct Tracker_Windows *window=static_cast<struct Tracker_Windows*>(root->song->tracker_windows); int num_lines = R_ABS(qwheelevent->delta()/120); //printf(" Got wheel event %d\n",qwheelevent->delta()/120); DO_GFX( { /* if(qwheelevent->delta()<0) ScrollEditorDown(window,num_lines * getScrollMultiplication()); else ScrollEditorUp(window,num_lines * getScrollMultiplication()); */ if (qwheelevent->modifiers() & Qt::ControlModifier) { if (qwheelevent->delta() > 0) zoom(1,window->l.num); else zoom(-1,window->l.num); #if 0 } else if (qwheelevent->modifiers() & Qt::ShiftModifier) { tevent.ID=TR_KEYBOARD; if(qwheelevent->delta()<0) tevent.SubID=EVENT_LEFTARROW; else tevent.SubID=EVENT_RIGHTARROW; for(int i=0;i<num_lines;i++) EventReciever(&tevent,window); #endif } else { tevent.ID=TR_KEYBOARD; if(qwheelevent->delta()<0) tevent.SubID=EVENT_DOWNARROW; else tevent.SubID=EVENT_UPARROW; for(int i=0;i<num_lines;i++) EventReciever(&tevent,window); } });
static void PlayerFirstLine(struct PEventQueue *peq,int doit){ #ifdef WITH_PD int64_t next_time = ATOMIC_GET(pc->seqtime) + peq->block->times[1].time; RT_PD_set_line(peq->l.time, next_time, 0); //printf("FirstLine: %d, time: %d, nextrealline: %d, nexttime: %d, addplaypos: %d, pc->seqtime: %d\n",(int)0,(int)peq->l.time,(int)peq->realline,(int)next_time,(int)0,(int)pc->seqtime); //fflush(stdout); #endif ReturnPEQelement(peq); }
void mbuf_recycle(struct context *ctx, struct mbuf *mbuf) { ATOMIC_DEC(ctx->mstats.buffers, 1); if (ATOMIC_GET(ctx->mstats.free_buffers) > RECYCLE_LENGTH) { mbuf_free(ctx, mbuf); return; } TAILQ_NEXT(mbuf, next) = NULL; TAILQ_INSERT_HEAD(&ctx->free_mbufq, mbuf, next); ATOMIC_INC(ctx->mstats.free_buffers, 1); }
static void DrawAllWTrackNames( struct Tracker_Windows *window, struct WBlocks *wblock ) { struct WTracks *wtrack1 = (struct WTracks *)ListFindElement1(&wblock->wtracks->l,wblock->left_track); if (wtrack1==NULL) return; int tracknum1 = wtrack1->l.num; int channelnum1 = ATOMIC_GET(wtrack1->track->midi_channel); struct Patch *patch1 = wtrack1->track->patch; struct WTracks *wtrack2 = NextWTrack(wtrack1); int tracknum2 = tracknum1; for(;;){ int channelnum2 = wtrack2==NULL ? 0 : ATOMIC_GET(wtrack2->track->midi_channel); if (wtrack2==NULL || wtrack2->track->patch==NULL || patch1==NULL || wtrack2->track->patch != patch1 || channelnum2 != channelnum1){ DrawWTrackNames(window, wblock, tracknum1, tracknum2); tracknum1 = tracknum2 = tracknum2+1; channelnum1 = channelnum2; patch1 = wtrack2==NULL ? NULL : wtrack2->track->patch; } else { tracknum2++; } if (wtrack2==NULL) break; else wtrack2 = NextWTrack(wtrack2); } }
static void setit(struct WBlocks *wblock, int realline){ if (!ATOMIC_GET(root->play_cursor_onoff)){ // Set current realline in main thread (main thread picks up till_curr_realline and sets curr_realline afterwards) //printf(" Setting till_curr_realline to %d\n", realline); ATOMIC_SET(wblock->till_curr_realline, realline); // Set current realline in opengl thread //printf("PEQ: set realline %d\n",realline); GE_set_curr_realline(realline); } PC_Pause_set_pos(wblock->l.num, realline); }
void BACKUP_call_very_often(void){ if (MIXER_is_saving()) return; if (g_radium_runs_custom_exec) return; static bool has_inited = false; if (has_inited==false){ RT_BACKUP_reset_timer(); has_inited=true; } if (!editor_has_keyboard_focus()) // If showing popup menu, editing text widgets, etc. we don't want to disturb the user. return; if (QApplication::mouseButtons() != Qt::NoButton) // Wait until user doesn't use the mouse. return; static bool is_playing = false; Player_State player_state = ATOMIC_GET(pc->player_state); if (!is_playing && player_state==PLAYER_STATE_PLAYING){ is_playing = true; g_curr_playing_start_time = TIME_get_ms(); } if (is_playing && player_state==PLAYER_STATE_STOPPED){ is_playing = false; double added_playing_duration = TIME_get_ms() - g_curr_playing_start_time; g_curr_playing_duration += added_playing_duration; } if (!doSaveBackupWhilePlaying()) if (is_playing) return; //printf("duration: %f\n",get_unbackuped_duration() / 1000.0); if (SampleRecorder_Get_Num_Instances() > 0) return; if (get_unbackuped_duration() > get_backup_interval_ms()){ make_backup(); RT_BACKUP_reset_timer(); } }
void timerEvent(QTimerEvent * e){ printf("clicked: %p\n", parent->msgBox->clickedButton()); if (parent->msgBox->clickedButton()!=NULL){ SOUNDFILESAVER_request_stop(); // Reset clickedButton(). delete parent->msgBox; parent->msgBox = new MyQMessageBox; } const char *message = ATOMIC_GET(async_message); if(message != NULL){ ATOMIC_SET(async_message, NULL); MIXER_request_stop_saving_soundfile(); // This is very messy. The code would be far simpler if jack_set_freewheel could be called from any thread. //usleep(1000*100); // Wait a bit for saving to stop; ScrollEditorToRealLine_CurrPos(root->song->tracker_windows, root->song->tracker_windows->wblock->bot_realline); root->song->tracker_windows->must_redraw = true; #if 0 MyQMessageBox msgBox; msgBox->setText(QString(message)); //msgBox->setInformativeText(message); msgBox->setStandardButtons(QMessageBox::Ok); safeExec(msgBox); #endif bool was_cancelled = !strcmp(message, "Cancelled"); V_free((void*)message); stop(); parent->clean_prev(); if (was_cancelled) PlayStop(); // Sometimes it continues playing after pressing "cancel". else parent->save_next(); } }
void polyKeyDownPlay(int notenum,int windownum){ //printf("POLY: doautorepeat: %d, autorepeat: %d\n", doAutoRepeat(), AutoRepeat(tevent.keyswitch)); if (!doAutoRepeat() && tevent_autorepeat) return; struct Tracker_Windows *window=getWindowFromNum(windownum); notenum+=root->keyoct; if(notenum<=0 || notenum>127) return; if(window==NULL || window->curr_track<0) return; PATCH_playNoteCurrPos(window,notenum,-1); if(ATOMIC_GET(root->editonoff)) InsertNoteCurrPos(window,notenum,true,-1); }
static bool paste_track( struct WBlocks *wblock, struct WTracks *wtrack, struct WTracks *towtrack ) { struct Tracks *totrack = towtrack->track; struct Tracks *track = wtrack->track; Place *p1,p2; towtrack->notelength=wtrack->notelength; towtrack->fxwidth=wtrack->fxwidth; totrack->onoff=track->onoff; totrack->pan=track->pan; totrack->volume=track->volume; totrack->panonoff=track->panonoff; totrack->volumeonoff=track->volumeonoff; ATOMIC_SET(totrack->midi_channel, ATOMIC_GET(track->midi_channel)); if(track->midi_instrumentdata!=NULL){ totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track); } totrack->trackname=talloc_strdup(track->trackname); totrack->notes=NULL; totrack->stops=NULL; VECTOR_clean(&totrack->fxs); p1=PlaceGetFirstPos(); PlaceSetLastPos(wblock->block,&p2); CopyRange_notes(&totrack->notes,track->notes,p1,&p2); CopyRange_stops(&totrack->stops,track->stops,p1,&p2); if (totrack->patch != NULL) CopyRange_fxs(&totrack->fxs,&track->fxs,p1,&p2); LegalizeFXlines(wblock->block,totrack); LegalizeNotes(wblock->block,totrack); return true; }
// OPTIMAL 4x 4 point 4th order interpolation routine written by Olli Niemitalo. // http://yehar.com/blog/wp-content/uploads/2009/08/deip-original.pdf // (Original code mashed through faust. Faust reduced the number of adds/subtractions from 17 to 14, but weren't able to reduce the number of multiplications (14)). static float cubic_interpolate( float y0,float y1, float y2,float y3, float mu) { if (true || ATOMIC_GET(root->editonoff)) return cubic_interpolate_old(y0,y1,y2,y3,mu); // *: 14 // +/-: 14 float fTemp0 = y3; //(float)input3[i]; float fTemp1 = y0; //(float)input0[i]; float fTemp2 = (fTemp1 + fTemp0); float fTemp3 = y2; //(float)input2[i]; float fTemp4 = y1; //(float)input1[i]; float fTemp5 = (fTemp4 + fTemp3); float fTemp6 = (fTemp0 - fTemp1); float fTemp7 = (fTemp3 - fTemp4); float fTemp8 = mu - 0.5f; //((float)input4[i] - 0.5f); return (fTemp8 * ((fTemp8 * (((fTemp8 * (((((0.00986988334359864f * fTemp5) - (0.00989340017126506f * fTemp2)) * fTemp8) + (0.15578800670302476f * fTemp6)) - (0.46896069955075126f * fTemp7))) + (0.2519474493593906f * fTemp2)) - (0.25194210134021744f * fTemp5))) + ((0.5374383075356016f * fTemp7) + (0.1542946255730746f * fTemp6)))) + ((0.4656725512077849f * fTemp5) + (0.03432729708429672f * fTemp2)); }
int32_t set_rand(void) { /* this fd will not close */ static volatile int fd = -1; int32_t value = 0; int tmp = 0; if(ATOMIC_GET(fd) == -1) { tmp = open("/dev/urandom", O_RDONLY); if(tmp == -1) { return mq_errno(); } if(ATOMIC_CAS(fd, -1, tmp) != -1) { close(tmp); } } return (read(fd, &value, sizeof(value)) == sizeof(value)) ? (value & 0x7FFFFFFF) : mq_errno(); }
void PC_NewSecond(struct PEventQueue *peq,int doit){ // ObtainRSemaphore(ClockSemaphore); // clock_time=time; clock_time=ATOMIC_GET(pc->therealtime); #ifdef _AMIGA Signal(mytask,1L<<clocksig); #else Ptask2Mtask(); #endif // ReleaseRSemaphore(ClockSemaphore); peq->l.time+=pc->pfreq*(pc->block->reltempo>1.0f?1.0f:pc->block->reltempo); ListAddElementP(&pc->peq,&peq->l); }
void UpdateClock( struct Tracker_Windows *window ){ #if 0 int clock_minutes,clock_seconds; char temp[52]; int64_t time=clock_time; static int64_t last_time = -1; if( ! ATOMIC_GET(pc->isplaying)){ if(last_time==-2) return; GFX_UpdateQuantitize(window,window->wblock); last_time = -2; return; } if(last_time==time) return; clock_minutes=time/(60*pc->pfreq); clock_seconds=time/pc->pfreq - (60*clock_minutes); // ObtainRSemaphore(ClockSemaphore); sprintf(temp,"%.02d:%.02d",clock_minutes,clock_seconds); GFX_Text( window,2,temp,0,0,TEXT_IGNORE_WIDTH,TEXT_CLEAR,PAINT_DIRECTLY ); last_time = time; // ReleaseRSemaphore(ClockSemaphore); #endif }