static void start_note(HmSynth *base, int num, float velocity) { SineSynth *synth = (SineSynth *)base; synth->note = num; float freq = midi_to_freq(num); osc_set_freq(&synth->osc, freq, synth->sampleRate); env_start(&synth->env); env_start(&synth->fenv); synth->filter.cutoff = freq * 2; lp2_recalc(&synth->filter, synth->sampleRate); }
void SimulationLoop() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test->SetTextLine(30); settings.hz = settingsHz; //////////////////////////////////////////////////////////////////////////////////////////// if(start==0){ last_state_main = env_start(); last_action_main = agent_start(last_state_main); start = 1; }else{ env_step1(last_action_main); test->Step(&settings); ro_main=env_step2(); if(ro_main->terminal == 1){ agent_end(ro_main->reward); start = 0; env_reset(); if(ro_main->reward==100){ success++; printf("success %d\tfail %d\tprob %lf\n",success,fail,(double)success/(double)(success+fail)*100); }else{ fail++; } //test->Step(&settings); }else{ last_action_main = agent_step(ro_main->reward, ro_main->observation); } } //////////////////////////////////////////////////////////////////////////////////////////// /*test->Step(&settings);*/ //////////////////////////////////////////////////////////////////////////////////////////// /*ro = env_step2(); this_reward = ro->reward; last_state = ro->observation; roa.reward = ro->reward; roa.observation = ro->observation; roa.terminal = ro->terminal;*/ //////////////////////////////////////////////////////////////////////////////////////////// test->DrawTitle(5, 15, entry->name); glutSwapBuffers(); if (testSelection != testIndex) { testIndex = testSelection; delete test; entry = g_testEntries + testIndex; test = entry->createFcn(); viewZoom = 1.0f; viewCenter.Set(0.0f, 20.0f); Resize(width, height); } }