//--------------------------------------------------------------------------------------- void DlgMetronome::increment_tempo() { m_tempo++; if (m_tempo > 300) m_tempo = 300; set_tempo(m_tempo); }
//--------------------------------------------------------------------------------------- void DlgMetronome::decrement_tempo() { m_tempo--; if (m_tempo < 1) m_tempo = 1; set_tempo(m_tempo); }
int mdx_init_track_work_area_ym2151( songdata *data ) { int i; __GETMDX(data); self->fade_out = 0; mdx->tempo = 200; mdx->total_count = 0; mdx->elapsed_time = 0; mdx->fm_noise_vol = 0; mdx->fm_noise_freq = 0; for ( i=0 ; i<mdx->tracks ; i++ ) { mdx->track[i].counter = 1; mdx->track[i].gate = 1; mdx->track[i].current_mml_ptr = mdx->mml_data_offset[i]; mdx->track[i].voice = 0; mdx->track[i].volume = 64; mdx->track[i].volume_normal = 8; mdx->track[i].note = 0; mdx->track[i].phase = MDX_PAN_C; mdx->track[i].quantize1 = 8; mdx->track[i].quantize2 = 0; mdx->track[i].detune = 0; if ( i<8 ) ym2151_set_detune(i,0, data); mdx->track[i].portament = 0; if ( i<8 ) ym2151_set_portament(i,0, data); mdx->track[i].loop_depth = 0; mdx->track[i].infinite_loop_times = 0; mdx->track[i].p_lfo_flag = FLAG_FALSE; mdx->track[i].a_lfo_flag = FLAG_FALSE; mdx->track[i].h_lfo_flag = FLAG_FALSE; mdx->track[i].p_lfo_form = 0; mdx->track[i].p_lfo_clock = 255; mdx->track[i].p_lfo_depth = 0; mdx->track[i].a_lfo_form = 0; mdx->track[i].a_lfo_clock = 255; mdx->track[i].a_lfo_depth = 0; mdx->track[i].waiting_sync = FLAG_FALSE; mdx->track[i].keyoff_disable = FLAG_FALSE; mdx->track[i].last_volume_normal = FLAG_FALSE; } set_tempo(mdx->tempo, data); return 0; }
blargg_err_t Sgc_Core::load_( Data_Reader& dr ) { RETURN_ERR( Sgc_Impl::load_( dr ) ); if ( sega_mapping() && fm_apu_.supported() ) RETURN_ERR( fm_apu_.init( clock_rate(), clock_rate() / 72 ) ); set_tempo( 1.0 ); return blargg_ok; }
//--------------------------------------------------------------------------------------- void DlgMetronome::compute_tapped_tempo() { ptime now = microsec_clock::universal_time(); time_duration diff = now - m_prevTime; double period( diff.total_milliseconds() ); //millisecods m_prevTime = now; if (period > 10000.0) return; set_tempo(60000.0 / period); }
void Ay_Emu::cpu_out_misc( cpu_time_t time, unsigned addr, int data ) { if ( !cpc_mode ) { switch ( addr & 0xFEFF ) { case 0xFEFD: spectrum_mode = true; apu_addr = data & 0x0F; return; case 0xBEFD: spectrum_mode = true; apu.write( time, apu_addr, data ); return; } } if ( !spectrum_mode ) { switch ( addr >> 8 ) { case 0xF6: switch ( data & 0xC0 ) { case 0xC0: apu_addr = cpc_latch & 0x0F; goto enable_cpc; case 0x80: apu.write( time, apu_addr, cpc_latch ); goto enable_cpc; } break; case 0xF4: cpc_latch = data; goto enable_cpc; } } debug_printf( "Unmapped OUT: $%04X <- $%02X\n", addr, data ); return; enable_cpc: if ( !cpc_mode ) { cpc_mode = true; change_clock_rate( cpc_clock ); set_tempo( tempo() ); } }
// Timer registers have been loaded. Applies these to the timers. Does not // reset timer prescalers or dividers. void SNES_SPC::timers_loaded() { int i; for ( i = 0; i < timer_count; i++ ) { Timer* t = &m.timers [i]; t->period = IF_0_THEN_256( REGS [r_t0target + i] ); t->enabled = REGS [r_control] >> i & 1; t->counter = REGS_IN [r_t0out + i] & 0x0F; } set_tempo( m.tempo ); }
static void set_opm_reg( int track, int v1, int v2, songdata *data ) { __GETMDX(data); if ( track<8 ) { ym2151_set_reg( v1, v2, data ); } if ( v1 == 0x12 ) { set_tempo(v2, data); } return; }
//--------------------------------------------------------------------------------------- void DlgMetronome::on_update_number(wxCommandEvent& WXUNUSED(event)) { wxString value = m_pTempoDisplay->GetValue(); long num = 0L; if (value.ToLong(&num)) { m_tempo = num; if (m_tempo < 1) m_tempo = 1; else if (m_tempo > 300) m_tempo = 300; } set_tempo(m_tempo); display_tempo(); }
void Gym_Emu::set_tempo_( double t ) { if ( t < min_tempo ) { set_tempo( min_tempo ); return; } if ( stereo_buf.sample_rate() ) { double denom = tempo() * 60; clocks_per_frame = (int) (clock_rate / denom); resampler.resize( (int) (sample_rate() / denom) ); } }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect window_bounds = layer_get_bounds(window_layer); // status layer status_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 - (42 / 2) - 28 - 5, window_bounds.size.w, 42)); text_layer_set_font(status_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_background_color(status_layer, GColorClear); text_layer_set_text_alignment(status_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(status_layer)); // output layer output_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 - (42 / 2) - 5, window_bounds.size.w, 42)); text_layer_set_font(output_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_background_color(output_layer, GColorClear); text_layer_set_text_color(output_layer, GColorWhite); text_layer_set_text_alignment(output_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(output_layer)); // bpm layer bpm_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 + (42 / 2) - 5, window_bounds.size.w, 42)); text_layer_set_font(bpm_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_background_color(bpm_layer, GColorClear); text_layer_set_text_color(bpm_layer, GColorWhite); text_layer_set_text_alignment(bpm_layer, GTextAlignmentCenter); text_layer_set_text(bpm_layer, "BPM"); layer_add_child(window_layer, text_layer_get_layer(bpm_layer)); // read stuff vibe_duration = (persist_exists(KEY_VIBE_DURATION) ? persist_read_int(KEY_VIBE_DURATION) : INITIAL_VIBE_DURATION); set_vibe(vibe_duration); set_tempo(persist_exists(KEY_TEMPO) ? persist_read_int(KEY_TEMPO) : INITIAL_TEMPO); color = get_color(); set_state(true); metronome_loop(); }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case MACRO_QWERTY: if (record->event.pressed) { persistant_default_layer_set(1UL<<LAYER_QWERTY); #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_qwerty, false, STACCATO); #endif /* AUDIO_ENABLE */ } break; case MACRO_COLEMAK: if (record->event.pressed) { persistant_default_layer_set(1UL<<LAYER_COLEMAK); #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_colemak, false, STACCATO); #endif /* AUDIO_ENABLE */ } break; case MACRO_DVORAK: if (record->event.pressed) { persistant_default_layer_set(1UL<<LAYER_DVORAK); #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_dvorak, false, STACCATO); #endif /* AUDIO_ENABLE */ } break; case MACRO_LOWER: if (record->event.pressed) { layer_on(LAYER_LOWER); update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); } break; case MACRO_RAISE: if (record->event.pressed) { layer_on(LAYER_RAISE); update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); } else { layer_off(LAYER_RAISE); update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); } break; case MACRO_FUNCTION: if (record->event.pressed) { layer_on(LAYER_FUNCTION); } else { layer_off(LAYER_FUNCTION); } break; #ifdef MOUSEKEY_ENABLE case MACRO_MOUSE: if (record->event.pressed) { layer_invert(LAYER_MOUSE); } break; #endif /* MOUSEKEY_ENABLE */ #ifdef AUDIO_ENABLE case MACRO_TIMBRE_1: if (record->event.pressed) set_timbre(TIMBRE_12); break; case MACRO_TIMBRE_2: if (record->event.pressed) set_timbre(TIMBRE_25); break; case MACRO_TIMBRE_3: if (record->event.pressed) set_timbre(TIMBRE_50); break; case MACRO_TIMBRE_4: if (record->event.pressed) set_timbre(TIMBRE_75); break; case MACRO_TEMPO_U: if (record->event.pressed) increase_tempo(10); break; case MACRO_TEMPO_D: if (record->event.pressed) decrease_tempo(10); break; case MACRO_TONE_DEFAULT: if (record->event.pressed) { set_timbre(TIMBRE_DEFAULT); set_tempo(TEMPO_DEFAULT); } break; case MACRO_AUDIO_OFF: if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_off(); #endif } break; case MACRO_AUDIO_ON: if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO); #endif } break; case MACRO_MUSIC_ON: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO); layer_on(LAYER_MUSIC); #endif } break; case MACRO_MUSIC_OFF: if (record->event.pressed) { #ifdef AUDIO_ENABLE layer_off(LAYER_MUSIC); stop_all_notes(); #endif } break; case MACRO_INC_VOICE: if (record->event.pressed) { #ifdef AUDIO_ENABLE voice_iterate(); PLAY_NOTE_ARRAY(music_scale, false, STACCATO); #endif } break; case MACRO_DEC_VOICE: if (record->event.pressed) { #ifdef AUDIO_ENABLE voice_deiterate(); PLAY_NOTE_ARRAY(music_scale, false, STACCATO); #endif } break; #endif /* AUDIO_ENABLE */ default: break; } return MACRO_NONE; };
blargg_err_t Nsf_Emu::load_( Data_Reader& in ) { assert( offsetof (header_t,unused [4]) == header_size ); RETURN_ERR( rom.load( in, header_size, &header_, 0 ) ); set_track_count( header_.track_count ); RETURN_ERR( check_nsf_header( &header_ ) ); if ( header_.vers != 1 ) set_warning( "Unknown file version" ); // sound and memory blargg_err_t err = init_sound(); if ( err ) return err; // set up data nes_addr_t load_addr = get_le16( header_.load_addr ); init_addr = get_le16( header_.init_addr ); play_addr = get_le16( header_.play_addr ); if ( !load_addr ) load_addr = rom_begin; if ( !init_addr ) init_addr = rom_begin; if ( !play_addr ) play_addr = rom_begin; if ( load_addr < rom_begin || init_addr < rom_begin ) { const char* w = warning(); if ( !w ) w = "Corrupt file (invalid load/init/play address)"; return w; } rom.set_addr( load_addr % bank_size ); int total_banks = rom.size() / bank_size; // bank switching int first_bank = (load_addr - rom_begin) / bank_size; for ( int i = 0; i < bank_count; i++ ) { unsigned bank = i - first_bank; if ( bank >= (unsigned) total_banks ) bank = 0; initial_banks [i] = bank; if ( header_.banks [i] ) { // bank-switched memcpy( initial_banks, header_.banks, sizeof initial_banks ); break; } } pal_only = (header_.speed_flags & 3) == 1; #if !NSF_EMU_EXTRA_FLAGS header_.speed_flags = 0; #endif set_tempo( tempo() ); return setup_buffer( (long) (clock_rate_ + 0.5) ); }
void init_player() { fill_freqs(); set_tempo(200); }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case MACRO_COPY_CUT: if (record->event.pressed) { register_code(KC_LCTL); if (record->tap.count == 1) { register_code(KC_C); unregister_code(KC_C); } else if (record->tap.count == 2) { register_code(KC_X); unregister_code(KC_X); } unregister_code(KC_LCTL); } break; // case MACRO_HELP_1: // if (record->event.pressed) // { // uprint("H1"); // } // break; // case MACRO_HELP_2: // if (record->event.pressed) // { // uprint("H2"); // } // break; // case MACRO_HELP_3: // if (record->event.pressed) // { // uprint("H3"); // } // break; // case MACRO_HELP_4: // if (record->event.pressed) // { // uprint("H4"); // } // break; // case MACRO_HELP_5: // if (record->event.pressed) // { // uprint("H5"); // } // break; // case MACRO_HELP_6: // if (record->event.pressed) // { // uprint("H6"); // } // break; // case MACRO_HELP_7: // if (record->event.pressed) // { // uprint("H7"); // } // break; // case MACRO_HELP_8: // if (record->event.pressed) // { // uprint("H8"); // } // break; // case MACRO_HELP_9: // if (record->event.pressed) // { // uprint("H9"); // } // break; case MACRO_BREATH_TOGGLE: if (record->event.pressed) { breathing_toggle(); } break; case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { breathing_speed_inc(1); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { breathing_speed_dec(1); } break; case MACRO_BREATH_DEFAULT: if (record->event.pressed) { breathing_defaults(); } break; case MACRO_QWERTY: if (record->event.pressed) { persistent_default_layer_set(1UL<<LAYER_QWERTY); } break; case MACRO_UPPER: if (record->event.pressed) { layer_on(LAYER_UPPER); breathing_speed_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_UPPER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_LOWER: if (record->event.pressed) { layer_on(LAYER_LOWER); breathing_speed_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_FUNCTION: if (record->event.pressed) { breathing_speed_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { breathing_speed_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } break; #ifdef MOUSEKEY_ENABLE case MACRO_MOUSE: if (record->event.pressed) { layer_invert(LAYER_MOUSE); } break; #endif /* MOUSEKEY_ENABLE */ #ifdef AUDIO_ENABLE case MACRO_TIMBRE_1: if (record->event.pressed) set_timbre(TIMBRE_12); break; case MACRO_TIMBRE_2: if (record->event.pressed) set_timbre(TIMBRE_25); break; case MACRO_TIMBRE_3: if (record->event.pressed) set_timbre(TIMBRE_50); break; case MACRO_TIMBRE_4: if (record->event.pressed) set_timbre(TIMBRE_75); break; case MACRO_TEMPO_U: if (record->event.pressed) increase_tempo(10); break; case MACRO_TEMPO_D: if (record->event.pressed) decrease_tempo(10); break; case MACRO_TONE_DEFAULT: if (record->event.pressed) { set_timbre(TIMBRE_DEFAULT); set_tempo(TEMPO_DEFAULT); } break; #endif /* AUDIO_ENABLE */ #ifdef BACKLIGHT_ENABLE case MACRO_BACKLIGHT: if (record->event.pressed) { backlight_step(); } break; #endif /* BACKLIGHT_ENABLE */ default: break; } return MACRO_NONE; };
//--------------------------------------------------------------------------------------- void DlgMetronome::on_tempo_choice(wxCommandEvent& event) { int i = m_pItalianTempo->GetSelection(); set_tempo( m_tempi[i].defaultTempo ); display_tempo(); }
/** * Mouse motion callback * */ gint scorearea_motion_notify (GtkWidget * widget, GdkEventButton * event) { DenemoProject *gui = Denemo.project; if (gui == NULL || gui->movement == NULL) return FALSE; if (Denemo.scorearea == NULL) return FALSE; gint allocated_height = get_widget_height (Denemo.scorearea); gint line_height = allocated_height * gui->movement->system_height; if(dragging_outside) { gint incrx, incry; incrx=incry=0; if(((gint)((last_event_x - event->x_root)/gui->movement->zoom)) != 0) { incrx = -(last_event_x - event->x_root)/gui->movement->zoom; last_event_x = event->x_root; } if( ((gint)((last_event_y - event->y_root)/gui->movement->zoom)) != 0) { incry = -(last_event_y - event->y_root)/gui->movement->zoom; last_event_y = event->y_root; } if((dragging_outside==DRAG_DIRECTION_RIGHT) && (incrx > 1) || ((dragging_outside==DRAG_DIRECTION_LEFT) && (incrx < -1)) || ((dragging_outside==DRAG_DIRECTION_UP) && (incry < 0)) || ((dragging_outside==DRAG_DIRECTION_DOWN) && (incry > 0))) extend_selection(dragging_outside); return TRUE; } if (event->y < 0) event->y = 0.0; gint line_num = ((int) event->y) / line_height; if (last_directive && (GDK_SHIFT_MASK & event->state) && (GDK_CONTROL_MASK & event->state)) { gint incrx, incry; incrx=incry=0; if(((gint)((last_event_x - event->x_root)/gui->movement->zoom)) != 0) { incrx = (last_event_x - event->x_root)/gui->movement->zoom; last_event_x = event->x_root; } if( ((gint)((last_event_y - event->y_root)/gui->movement->zoom)) != 0) { incry = (last_event_y - event->y_root)/gui->movement->zoom; last_event_y = event->y_root; } if(last_directive->graphic) { last_directive->gx -= incrx; last_directive->gy -= incry; } else { last_directive->tx -= incrx; last_directive->ty -= incry; } draw_score_area(); return TRUE; } if(gui->movement->recording && dragging_audio) { if(gui->movement->recording->type == DENEMO_RECORDING_MIDI) { #if 0 //This is moving only the NoteOn, so it could be moved later than the note off, and indeed later than a later note in the stream //- quite a bit more work needed to drag MIDI to correct the timing. smf_event_t *midievent; GList *marked_onset = gui->movement->marked_onset; if(marked_onset) { midievent = ((DenemoRecordedNote *)marked_onset->data)->event; gint shift = 2500*(event->x_root - last_event_x)/gui->movement->zoom; g_debug (" %f (%f %f)",shift/(double)gui->movement->recording->samplerate, midievent->time_seconds, ((DenemoRecordedNote *)marked_onset->data)->timing/(double)gui->movement->recording->samplerate) ; ((DenemoRecordedNote *)marked_onset->data)->timing += shift; midievent->time_seconds += shift/(double)gui->movement->recording->samplerate; } #endif g_warning("No drag for MIDI yet"); return TRUE; } gui->movement->recording->leadin -= 500*(event->x_root - last_event_x)/gui->movement->zoom;//g_debug("%d %d => %d\n", (int)(10*last_event_x), (int)(10*event->x_root), (int)(10*last_event_x) - (int)(10*event->x_root)); last_event_x = event->x_root; update_leadin_widget ( gui->movement->recording->leadin/(double)gui->movement->recording->samplerate); gtk_widget_queue_draw(Denemo.scorearea); return TRUE; } if(gui->movement->recording && dragging_tempo) { gdouble change = (event->x_root - last_event_x)/gui->movement->zoom; last_event_x = event->x_root; struct placement_info pi; get_placement_from_coordinates (&pi, event->x, 0, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]); change /= pi.measure_number; update_tempo_widget ( change); set_tempo (); score_status (Denemo.project, TRUE); exportmidi (NULL, gui->movement); gtk_widget_queue_draw(Denemo.scorearea); return TRUE; } #define DENEMO_MINIMUM_SYSTEM_HEIGHT (0.01) if (dragging_separator) { gui->movement->system_height = event->y / get_widget_height (Denemo.scorearea); if (gui->movement->system_height < DENEMO_MINIMUM_SYSTEM_HEIGHT) gui->movement->system_height = DENEMO_MINIMUM_SYSTEM_HEIGHT; if (gui->movement->system_height > 1.0) gui->movement->system_height = 1.0; scorearea_configure_event (Denemo.scorearea, NULL); draw_score_area(); return TRUE; } if (line_height - ((int) event->y - 8) % line_height < 12) gdk_window_set_cursor (gtk_widget_get_window (Denemo.window), gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW)); else gdk_window_set_cursor (gtk_widget_get_window (Denemo.window), gdk_cursor_new (GDK_LEFT_PTR)); //FIXME? does this take time/hog memory transform_coords (&event->x, &event->y); //g_debug("Marked %d\n", gui->movement->markstaffnum); if (gui->lefts[line_num] == 0) return TRUE; if (lh_down || (selecting && gui->movement->markstaffnum)) { struct placement_info pi; pi.the_staff = NULL; if (event->y < 0) get_placement_from_coordinates (&pi, event->x, 0, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]); else get_placement_from_coordinates (&pi, event->x, event->y, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]); if (pi.the_staff == NULL) return TRUE; //could not place the cursor if (pi.the_measure != NULL) { /*don't place cursor in a place that is not there */ change_staff (gui->movement, pi.staff_number, pi.the_staff); gui->movement->currentmeasurenum = pi.measure_number; gui->movement->currentmeasure = pi.the_measure; gui->movement->currentobject = pi.the_obj; gui->movement->cursor_x = pi.cursor_x; gui->movement->cursor_appending = (gui->movement->cursor_x == (gint) (g_list_length ((objnode *) ((DenemoMeasure*)gui->movement->currentmeasure->data)->objects))); set_cursor_y_from_click (gui, event->y); if (lh_down & !selecting) { if (gui->movement->markstaffnum) set_point (NULL, NULL); else set_mark (NULL, NULL); selecting = TRUE; } calcmarkboundaries (gui->movement); if (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) perform_command (event->state, GESTURE_MOVE, event->state & GDK_BUTTON1_MASK); /* redraw to show new cursor position */ draw_score_area(); } } if (Denemo.project->midi_destination & MIDICONDUCT) { advance_time (0.01); return TRUE; } return TRUE; }
static void down_click_handler(ClickRecognizerRef recognizer, void *context) { if (tempo > MIN) { set_tempo(tempo - INCREMENT); } }
inline void Ay_Emu::enable_cpc() { change_clock_rate( cpc_clock ); set_tempo( tempo() ); }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case MACRO_HELP_1: if (record->event.pressed) { uprintf("1"); } break; case MACRO_HELP_2: if (record->event.pressed) { uprintf("2"); } break; case MACRO_HELP_3: if (record->event.pressed) { uprintf("3"); } break; case MACRO_HELP_4: if (record->event.pressed) { uprintf("4"); } break; case MACRO_HELP_5: if (record->event.pressed) { uprintf("5"); } break; case MACRO_HELP_6: if (record->event.pressed) { uprintf("6"); } break; case MACRO_HELP_7: if (record->event.pressed) { uprintf("7"); } break; case MACRO_HELP_8: if (record->event.pressed) { uprintf("8"); } break; case MACRO_HELP_9: if (record->event.pressed) { uprintf("9"); } break; case MACRO_BREATH_TOGGLE: if (record->event.pressed) { breathing_toggle(); } break; case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { breathing_period_dec(); } break; case MACRO_BREATH_DEFAULT: if (record->event.pressed) { breathing_defaults(); } break; case MACRO_QWERTY: if (record->event.pressed) { persistent_default_layer_set(1UL<<LAYER_QWERTY); } break; case MACRO_UPPER: if (record->event.pressed) { layer_on(LAYER_UPPER); breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_UPPER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_LOWER: if (record->event.pressed) { layer_on(LAYER_LOWER); breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_FUNCTION: if (record->event.pressed) { breathing_period_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { breathing_period_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } break; #ifdef MOUSEKEY_ENABLE case MACRO_MOUSE: if (record->event.pressed) { layer_invert(LAYER_MOUSE); } break; #endif /* MOUSEKEY_ENABLE */ #ifdef AUDIO_ENABLE case MACRO_TIMBRE_1: if (record->event.pressed) set_timbre(TIMBRE_12); break; case MACRO_TIMBRE_2: if (record->event.pressed) set_timbre(TIMBRE_25); break; case MACRO_TIMBRE_3: if (record->event.pressed) set_timbre(TIMBRE_50); break; case MACRO_TIMBRE_4: if (record->event.pressed) set_timbre(TIMBRE_75); break; case MACRO_TEMPO_U: if (record->event.pressed) increase_tempo(10); break; case MACRO_TEMPO_D: if (record->event.pressed) decrease_tempo(10); break; case MACRO_TONE_DEFAULT: if (record->event.pressed) { set_timbre(TIMBRE_DEFAULT); set_tempo(TEMPO_DEFAULT); } break; /* case MACRO_AUDIO_TOGGLE: if (record->event.pressed) { if (is_audio_on()) { audio_off(); } else { audio_on(); PLAY_SONG(tone_audio_on); } } break; case MACRO_MUSIC_TOGGLE: if (record->event.pressed) { if (IS_LAYER_ON(LAYER_MUSIC)) { layer_off(LAYER_MUSIC); stop_all_notes(); } else { PLAY_SONG(tone_music_on); layer_on(LAYER_MUSIC); } } break; case MACRO_INC_VOICE: if (record->event.pressed) { #ifdef AUDIO_ENABLE voice_iterate(); PLAY_SONG(music_scale); #endif } break; case MACRO_DEC_VOICE: if (record->event.pressed) { #ifdef AUDIO_ENABLE voice_deiterate(); PLAY_SONG(music_scale); #endif } break; */ #endif /* AUDIO_ENABLE */ #ifdef BACKLIGHT_ENABLE case MACRO_BACKLIGHT: if (record->event.pressed) { backlight_step(); } #endif default: break; } return MACRO_NONE; };
static void up_click_handler(ClickRecognizerRef recognizer, void *context) { // click handlers if(tempo < MAX) { set_tempo(tempo + INCREMENT); } }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case MACRO_HELP_1: if (record->event.pressed) { uprintf("1"); } break; case MACRO_HELP_2: if (record->event.pressed) { uprintf("2"); } break; case MACRO_HELP_3: if (record->event.pressed) { uprintf("3"); } break; case MACRO_HELP_4: if (record->event.pressed) { uprintf("4"); } break; case MACRO_HELP_5: if (record->event.pressed) { uprintf("5"); } break; case MACRO_HELP_6: if (record->event.pressed) { uprintf("6"); } break; case MACRO_HELP_7: if (record->event.pressed) { uprintf("7"); } break; case MACRO_HELP_8: if (record->event.pressed) { uprintf("8"); } break; case MACRO_HELP_9: if (record->event.pressed) { uprintf("9"); } break; case MACRO_BREATH_TOGGLE: if (record->event.pressed) { #ifdef BACKLIGHT_BREATHING breathing_toggle(); #endif } break; case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { #ifdef BACKLIGHT_BREATHING breathing_period_inc(); #endif } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { #ifdef BACKLIGHT_BREATHING breathing_period_dec(); #endif } break; case MACRO_BREATH_DEFAULT: if (record->event.pressed) { #ifdef BACKLIGHT_BREATHING breathing_period_default(); #endif } break; case MACRO_QWERTY: if (record->event.pressed) { persistent_default_layer_set(1UL<<LAYER_QWERTY); } break; case MACRO_UPPER: if (record->event.pressed) { layer_on(LAYER_UPPER); #ifdef BACKLIGHT_BREATHING breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_UPPER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_LOWER: if (record->event.pressed) { layer_on(LAYER_LOWER); #ifdef BACKLIGHT_BREATHING breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_FUNCTION: if (record->event.pressed) { #ifdef BACKLIGHT_BREATHING breathing_period_set(3); breathing_enable(); #endif layer_on(LAYER_FUNCTION); } else { #ifdef BACKLIGHT_BREATHING breathing_period_set(1); breathing_self_disable(); #endif layer_off(LAYER_FUNCTION); } break; #ifdef BACKLIGHT_ENABLE case MACRO_BACKLIGHT: if (record->event.pressed) { backlight_step(); } #endif #ifdef MOUSEKEY_ENABLE case MACRO_MOUSE: if (record->event.pressed) { layer_invert(LAYER_MOUSE); } break; case MACRO_MOUSE_MOVE_UL: if (record->event.pressed) { mousekey_on(KC_MS_UP); mousekey_on(KC_MS_LEFT); } else { mousekey_off(KC_MS_UP); mousekey_off(KC_MS_LEFT); } break; case MACRO_MOUSE_MOVE_UR: if (record->event.pressed) { mousekey_on(KC_MS_UP); mousekey_on(KC_MS_RIGHT); } else { mousekey_off(KC_MS_UP); mousekey_off(KC_MS_RIGHT); } break; case MACRO_MOUSE_MOVE_DL: if (record->event.pressed) { mousekey_on(KC_MS_DOWN); mousekey_on(KC_MS_LEFT); } else { mousekey_off(KC_MS_DOWN); mousekey_off(KC_MS_LEFT); } break; case MACRO_MOUSE_MOVE_DR: if (record->event.pressed) { mousekey_on(KC_MS_DOWN); mousekey_on(KC_MS_RIGHT); } else { mousekey_off(KC_MS_DOWN); mousekey_off(KC_MS_RIGHT); } break; #endif /* MOUSEKEY_ENABLE */ #ifdef AUDIO_ENABLE case MACRO_TIMBRE_1: if (record->event.pressed) set_timbre(TIMBRE_12); break; case MACRO_TIMBRE_2: if (record->event.pressed) set_timbre(TIMBRE_25); break; case MACRO_TIMBRE_3: if (record->event.pressed) set_timbre(TIMBRE_50); break; case MACRO_TIMBRE_4: if (record->event.pressed) set_timbre(TIMBRE_75); break; case MACRO_TEMPO_U: if (record->event.pressed) increase_tempo(10); break; case MACRO_TEMPO_D: if (record->event.pressed) decrease_tempo(10); break; case MACRO_TONE_DEFAULT: if (record->event.pressed) { set_timbre(TIMBRE_DEFAULT); set_tempo(TEMPO_DEFAULT); } break; #endif /* AUDIO_ENABLE */ default: break; } return MACRO_NONE; };
//--------------------------------------------------------------------------------------- void DlgMetronome::on_tempo_slider(wxCommandEvent& WXUNUSED(event)) { set_tempo( m_pTempoSlider->GetValue() ); display_tempo(); }
static int set_new_event( int t ) { int ptr; unsigned char *data; int count; int follower; __GETMDX; data = mdx->data; ptr = mdx->track[t].current_mml_ptr; count = 0; follower = 0; #if 0 if ( ptr+1 <= mdx->length && t>7 ) { fprintf(stderr,"%2d %2x %2x\n",t,data[ptr],data[ptr+1]); fflush(stderr); } #endif if ( data[ptr] <= MDX_MAX_REST ) { /* rest */ note_off(t); count = data[ptr]+1; mdx->track[t].gate = count+1; follower=0; } else if ( data[ptr] <= MDX_MAX_NOTE ) { /* note */ note_on( t, data[ptr]); count = data[ptr+1]+1; do_quantize( t, count ); follower = 1; } else { switch ( data[ptr] ) { case MDX_SET_TEMPO: set_tempo( data[ptr+1] ); follower = 1; break; case MDX_SET_OPM_REG: set_opm_reg( t, data[ptr+1], data[ptr+2] ); follower = 2; break; case MDX_SET_VOICE: set_voice( t, data[ptr+1] ); follower = 1; break; case MDX_SET_PHASE: set_phase( t, data[ptr+1] ); follower = 1; break; case MDX_SET_VOLUME: set_volume( t, data[ptr+1] ); follower = 1; break; case MDX_VOLUME_DEC: dec_volume( t ); follower = 0; break; case MDX_VOLUME_INC: inc_volume( t ); follower = 0; break; case MDX_SET_QUANTIZE: set_quantize( t, data[ptr+1] ); follower = 1; break; case MDX_SET_KEYOFF: set_keyoff( t ); follower = 0; break; case MDX_REPEAT_START: mdx->track[t].loop_counter[mdx->track[t].loop_depth] = data[ptr+1]; if ( mdx->track[t].loop_depth < MDX_MAX_LOOP_DEPTH ) mdx->track[t].loop_depth++; follower = 2; break; case MDX_REPEAT_END: if (--mdx->track[t].loop_counter[mdx->track[t].loop_depth-1] == 0 ) { if ( --mdx->track[t].loop_depth < 0 ) mdx->track[t].loop_depth=0; } else { if ( data[ptr+1] >= 0x80 ) { ptr = ptr+2 - (0x10000-(data[ptr+1]*256 + data[ptr+2])) - 2; } else { ptr = ptr+2 + data[ptr+1]*256 + data[ptr+2] - 2; } } follower = 2; break; case MDX_REPEAT_BREAK: if ( mdx->track[t].loop_counter[mdx->track[t].loop_depth-1] == 1 ) { if ( --mdx->track[t].loop_depth < 0 ) mdx->track[t].loop_depth=0; ptr = ptr+2 + data[ptr+1]*256 + data[ptr+2] -2 +2; } follower = 2; break; case MDX_SET_DETUNE: set_detune( t, data[ptr+1], data[ptr+2] ); follower = 2; break; case MDX_SET_PORTAMENT: set_portament( t, data[ptr+1], data[ptr+2] ); follower = 2; break; case MDX_DATA_END: if ( data[ptr+1] == 0x00 ) { count = -1; note_off(t); follower = 1; } else { ptr = ptr+2 - (0x10000-(data[ptr+1]*256 + data[ptr+2])) - 2; mdx->track[t].infinite_loop_times++; follower = 2; } break; case MDX_KEY_ON_DELAY: follower = 1; break; case MDX_SEND_SYNC: send_sync( data[ptr+1] ); follower = 1; break; case MDX_RECV_SYNC: recv_sync( t ); follower = 0; count = 1; break; case MDX_SET_FREQ: set_freq( t, data[ptr+1] ); follower = 1; break; case MDX_SET_PLFO: if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) { set_plfo_onoff( t, data[ptr+1]-0x80 ); follower = 1; } else { set_plfo( t, data[ptr+1], data[ptr+2], data[ptr+3], data[ptr+4], data[ptr+5] ); follower = 5; } break; case MDX_SET_ALFO: if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) { set_alfo_onoff( t, data[ptr+1]-0x80 ); follower = 1; } else { set_alfo( t, data[ptr+1], data[ptr+2], data[ptr+3], data[ptr+4], data[ptr+5] ); follower = 5; } break; case MDX_SET_OPMLFO: if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) { set_hlfo_onoff( t, data[ptr+1]-0x80 ); follower = 1; } else { set_hlfo( t, data[ptr+1], data[ptr+2], data[ptr+3], data[ptr+4], data[ptr+5] ); follower = 5; } break; case MDX_SET_LFO_DELAY: set_lfo_delay( t, data[ptr+1] ); follower = 1; break; case MDX_SET_PCM8_MODE: follower = 0; break; case MDX_FADE_OUT: if ( data[ptr+1]==0x00 ) { follower = 1; set_fade_out( 5 ); } else { follower = 2; set_fade_out( data[ptr+2] ); } break; default: count = -1; break; } } ptr += 1+follower; mdx->track[t].current_mml_ptr = ptr; return count; }
SMP::SMP() : dsp( *this ), timer0( *this ), timer1( *this ), timer2( *this ), clock( 0 ) { for(auto& byte : iplrom) byte = 0; set_sfm_queue(0, 0, 0); set_tempo(1.0); }
blargg_err_t Ay_Emu::start_track_( int track ) { RETURN_ERR( Classic_Emu::start_track_( track ) ); memset( mem.ram + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET memset( mem.ram + 0x0100, 0xFF, 0x4000 - 0x100 ); memset( mem.ram + ram_start, 0x00, sizeof mem.ram - ram_start ); memset( mem.padding1, 0xFF, sizeof mem.padding1 ); memset( mem.ram + 0x10000, 0xFF, sizeof mem.ram - 0x10000 ); // locate data blocks byte const* const data = get_data( file, file.tracks + track * 4 + 2, 14 ); if ( !data ) return "File data missing"; byte const* const more_data = get_data( file, data + 10, 6 ); if ( !more_data ) return "File data missing"; byte const* blocks = get_data( file, data + 12, 8 ); if ( !blocks ) return "File data missing"; // initial addresses cpu::reset( mem.ram ); r.sp = get_be16( more_data ); r.b.a = r.b.b = r.b.d = r.b.h = data [8]; r.b.flags = r.b.c = r.b.e = r.b.l = data [9]; r.alt.w = r.w; r.ix = r.iy = r.w.hl; unsigned addr = get_be16( blocks ); if ( !addr ) return "File data missing"; unsigned init = get_be16( more_data + 2 ); if ( !init ) init = addr; // copy blocks into memory do { blocks += 2; unsigned len = get_be16( blocks ); blocks += 2; if ( addr + len > 0x10000 ) { set_warning( "Bad data block size" ); len = 0x10000 - addr; } check( len ); byte const* in = get_data( file, blocks, 0 ); blocks += 2; if ( len > blargg_ulong (file.end - in) ) { set_warning( "Missing file data" ); len = file.end - in; } //debug_printf( "addr: $%04X, len: $%04X\n", addr, len ); if ( addr < ram_start && addr >= 0x400 ) // several tracks use low data debug_printf( "Block addr in ROM\n" ); memcpy( mem.ram + addr, in, len ); if ( file.end - blocks < 8 ) { set_warning( "Missing file data" ); break; } } while ( (addr = get_be16( blocks )) != 0 ); // copy and configure driver static byte const passive [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x5E, // LOOP: IM 2 0xFB, // EI 0x76, // HALT 0x18, 0xFA // JR LOOP }; static byte const active [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x56, // LOOP: IM 1 0xFB, // EI 0x76, // HALT 0xCD, 0, 0, // CALL play 0x18, 0xF7 // JR LOOP }; memcpy( mem.ram, passive, sizeof passive ); unsigned play_addr = get_be16( more_data + 4 ); //debug_printf( "Play: $%04X\n", play_addr ); if ( play_addr ) { memcpy( mem.ram, active, sizeof active ); mem.ram [ 9] = play_addr; mem.ram [10] = play_addr >> 8; } mem.ram [2] = init; mem.ram [3] = init >> 8; mem.ram [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET) memcpy( mem.ram + 0x10000, mem.ram, 0x80 ); // some code wraps around (ugh) beeper_delta = int (apu.amp_range * 0.65); last_beeper = 0; apu.reset(); next_play = play_period; // start at spectrum speed change_clock_rate( spectrum_clock ); set_tempo( tempo() ); spectrum_mode = false; cpc_mode = false; cpc_latch = 0; return 0; }
blargg_err_t Music_Emu::post_load() { set_tempo( tempo_ ); remute_voices(); return Gme_File::post_load(); }
blargg_err_t Ay_Emu::start_track_( int track ) { RETURN_ERR( Classic_Emu::start_track_( track ) ); byte* const mem = core.mem(); memset( mem + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET memset( mem + 0x0100, 0xFF, 0x4000 - 0x100 ); memset( mem + core.ram_addr, 0x00, core.mem_size - core.ram_addr ); // locate data blocks byte const* const data = get_data( file, file.tracks + track * 4 + 2, 14 ); if ( !data ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); byte const* const more_data = get_data( file, data + 10, 6 ); if ( !more_data ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); byte const* blocks = get_data( file, data + 12, 8 ); if ( !blocks ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); // initial addresses unsigned addr = get_be16( blocks ); if ( !addr ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); unsigned init = get_be16( more_data + 2 ); if ( !init ) init = addr; // copy blocks into memory do { blocks += 2; unsigned len = get_be16( blocks ); blocks += 2; if ( addr + len > core.mem_size ) { set_warning( "Bad data block size" ); len = core.mem_size - addr; } check( len ); byte const* in = get_data( file, blocks, 0 ); blocks += 2; if ( len > (unsigned) (file.end - in) ) { set_warning( "File data missing" ); len = file.end - in; } //dprintf( "addr: $%04X, len: $%04X\n", addr, len ); if ( addr < core.ram_addr && addr >= 0x400 ) // several tracks use low data dprintf( "Block addr in ROM\n" ); memcpy( mem + addr, in, len ); if ( file.end - blocks < 8 ) { set_warning( "File data missing" ); break; } } while ( (addr = get_be16( blocks )) != 0 ); // copy and configure driver static byte const passive [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x5E, // LOOP: IM 2 0xFB, // EI 0x76, // HALT 0x18, 0xFA // JR LOOP }; static byte const active [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x56, // LOOP: IM 1 0xFB, // EI 0x76, // HALT 0xCD, 0, 0, // CALL play 0x18, 0xF7 // JR LOOP }; memcpy( mem, passive, sizeof passive ); int const play_addr = get_be16( more_data + 4 ); if ( play_addr ) { memcpy( mem, active, sizeof active ); mem [ 9] = play_addr; mem [10] = play_addr >> 8; } mem [2] = init; mem [3] = init >> 8; mem [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET) // start at spectrum speed change_clock_rate( spectrum_clock ); set_tempo( tempo() ); Ay_Core::registers_t r = { }; r.sp = get_be16( more_data ); r.b.a = r.b.b = r.b.d = r.b.h = data [8]; r.b.flags = r.b.c = r.b.e = r.b.l = data [9]; r.alt.w = r.w; r.ix = r.iy = r.w.hl; core.start_track( r, play_addr ); return blargg_ok; }