示例#1
0
int SynthWindow::resize_event(int w, int h)
{
	clear_box(0, 0, w, h);
	osc_subwindow->reposition_window(osc_subwindow->get_x(), 
		osc_subwindow->get_y(), 
		osc_subwindow->get_w(), 
		h - osc_subwindow->get_y());
	osc_subwindow->clear_box(0, 0, osc_subwindow->get_w(), osc_subwindow->get_h());
	osc_scroll->reposition_window(osc_scroll->get_x(), 
		osc_scroll->get_y(), 
		h - osc_scroll->get_y());
	note_subwindow->reposition_window(note_subwindow->get_x(),
		note_subwindow->get_y(),
		w - note_subwindow->get_x(),
		note_subwindow->get_h());
	note_scroll->reposition_window(note_scroll->get_x(),
		note_scroll->get_y(),
		w - note_scroll->get_x());
	note_scroll->update_length(white_key[0]->get_w() * TOTALNOTES * 7 / 12 +
			white_key[0]->get_w(), 
		note_scroll->get_position(), 
		note_subwindow->get_w(),
		0);
	
	update_scrollbar();
	update_notes();
	update_oscillators();
	synth->window_w = w;
	synth->window_h = h;
	return 1;
}
示例#2
0
void PlantsWindow::update_plant_data(const QModelIndex& current_plant_mi, const QModelIndex& previous_plant_mi)
{
    int previous_plant_index = previous_plant_mi.row();
    int current_plant_index = current_plant_mi.row();
    update_btns_state();
    update_notes(current_plant_index, previous_plant_index);
    update_del_btn(current_plant_index);
    emit timeline_need_update();
}
示例#3
0
文件: tk_c.c 项目: avm/timidity
/*ARGSUSED*/
static int TraceUpdate(ClientData clientData, Tcl_Interp *interp,
		    int argc, char *argv[])
{
	const char *playing = v_get2("Stat", "Playing");
	if (playing && *playing != '0') {
		if (Panel->reset_panel) {
			v_eval("TraceReset");
			Panel->reset_panel = 0;
		}
		if (Panel->last_time != Panel->cur_time) {
			v_eval("SetTime %d", Panel->cur_time);
			Panel->last_time = Panel->cur_time;
		}
		if (ctl.trace_playing)
			update_notes();
	}
	v_eval("set Stat(TimerId) [after 50 TraceUpdate]");
	return TCL_OK;
}
示例#4
0
void SynthWindow::create_objects()
{
	BC_MenuBar *menu;
	add_subwindow(menu = new BC_MenuBar(0, 0, get_w()));

	BC_Menu *levelmenu, *phasemenu, *harmonicmenu;
	menu->add_menu(levelmenu = new BC_Menu(_("Level")));
	menu->add_menu(phasemenu = new BC_Menu(_("Phase")));
	menu->add_menu(harmonicmenu = new BC_Menu(_("Harmonic")));

	levelmenu->add_item(new SynthLevelInvert(synth));
	levelmenu->add_item(new SynthLevelMax(synth));
	levelmenu->add_item(new SynthLevelRandom(synth));
	levelmenu->add_item(new SynthLevelSine(synth));
	levelmenu->add_item(new SynthLevelSlope(synth));
	levelmenu->add_item(new SynthLevelZero(synth));

	phasemenu->add_item(new SynthPhaseInvert(synth));
	phasemenu->add_item(new SynthPhaseRandom(synth));
	phasemenu->add_item(new SynthPhaseSine(synth));
	phasemenu->add_item(new SynthPhaseZero(synth));

	harmonicmenu->add_item(new SynthFreqEnum(synth));
	harmonicmenu->add_item(new SynthFreqEven(synth));
	harmonicmenu->add_item(new SynthFreqFibonacci(synth));
	harmonicmenu->add_item(new SynthFreqOdd(synth));
	harmonicmenu->add_item(new SynthFreqPrime(synth));

	int x = 10, y = 30;
	
	add_subwindow(new BC_Title(x, y, _("Waveform")));
	x += 240;
	add_subwindow(new BC_Title(x, y, _("Wave Function")));
	y += 20;
	x = 10;
	add_subwindow(canvas = new SynthCanvas(synth, this, x, y, 230, 160));
	canvas->update();

	x += 240;
	char string[BCTEXTLEN];
	waveform_to_text(string, synth->config.wavefunction);

	add_subwindow(waveform = new SynthWaveForm(synth, x, y, string));
	waveform->create_objects();
	y += 30;
	int x1 = x + waveform->get_w() + 10;


	add_subwindow(new BC_Title(x, y, _("Base Frequency:")));
	y += 30;
	add_subwindow(base_freq = new SynthBaseFreq(synth, this, x, y));
	base_freq->update((float)synth->config.base_freq[0]);
	x += base_freq->get_w() + synth->get_theme()->widget_border;
	add_subwindow(freqpot = new SynthFreqPot(synth, this, x, y - 10));
	base_freq->freq_pot = freqpot;
	freqpot->freq_text = base_freq;
	x -= base_freq->get_w() + synth->get_theme()->widget_border;
	y += 40;
	add_subwindow(new BC_Title(x, y, _("Wetness:")));
	add_subwindow(wetness = new SynthWetness(synth, x + 70, y - 10));

	y += 40;
	add_subwindow(new SynthClear(synth, x, y));


	x = 50;  
	y = 220;
	add_subwindow(new BC_Title(x, y, _("Level"))); 
	x += 75;
	add_subwindow(new BC_Title(x, y, _("Phase"))); 
	x += 75;
	add_subwindow(new BC_Title(x, y, _("Harmonic")));



	y += 20; x = 10;
	add_subwindow(osc_subwindow = new BC_SubWindow(x, y, 265, get_h() - y));
	x += 265;
	add_subwindow(osc_scroll = new OscScroll(synth, this, x, y, get_h() - y));


	x += 20;
	add_subwindow(new SynthAddOsc(synth, this, x, y));
	y += 30;
	add_subwindow(new SynthDelOsc(synth, this, x, y));

// Create keyboard
	y = 30;

#include "white_up_png.h"
#include "white_hi_png.h"
#include "white_dn_png.h"
#include "white_checked_png.h"
#include "white_checkedhi_png.h"
#include "black_up_png.h"
#include "black_hi_png.h"
#include "black_dn_png.h"
#include "black_checked_png.h"
#include "black_checkedhi_png.h"
	white_key[0] = new VFrame(white_up_png);
	white_key[1] = new VFrame(white_hi_png);
	white_key[2] = new VFrame(white_checked_png);
	white_key[3] = new VFrame(white_dn_png);
	white_key[4] = new VFrame(white_checkedhi_png);
	black_key[0] = new VFrame(black_up_png);
	black_key[1] = new VFrame(black_hi_png);
	black_key[2] = new VFrame(black_checked_png);
	black_key[3] = new VFrame(black_dn_png);
	black_key[4] = new VFrame(black_checkedhi_png);


	add_subwindow(note_subwindow = new BC_SubWindow(x1, 
		y, 
		get_w() - x1, 
		white_key[0]->get_h() + MARGIN +
		get_text_height(MEDIUMFONT) + MARGIN +
		get_text_height(MEDIUMFONT) + MARGIN));
	add_subwindow(note_scroll = new NoteScroll(synth,
		this,
		x1,
		note_subwindow->get_y() + note_subwindow->get_h(),
		note_subwindow->get_w()));

	add_subwindow(momentary = new SynthMomentary(this, 
		x1, 
		note_scroll->get_y() + note_scroll->get_h() + MARGIN, 
		_("Momentary notes")));


	add_subwindow(note_instructions = new BC_Title(
		x1,
		momentary->get_y() + momentary->get_h() + MARGIN,
		_("Ctrl or Shift to select multiple notes.")));

	update_scrollbar();
	update_oscillators();
	update_notes();

	show_window();
}
示例#5
0
文件: main.c 项目: f16falcona46/PSoC
int main() {
	
	int noteBuffer[SONG_SIZE];
	int accidentals[SONG_SIZE];
	int octaveBuffer[SONG_SIZE];
	
	memcpy(noteBuffer, rom_notes, SONG_SIZE*sizeof(int));
	memcpy(accidentals, rom_accidentals, SONG_SIZE*sizeof(int));
	memcpy(octaveBuffer, rom_octaves, SONG_SIZE*sizeof(int));
	const int buf_size = SONG_SIZE;
    
    //uint8 selected;
	initHardware();
	int start = 0;
	while (1) {
		//glcd_clear();
		glcd_tiny_set_font(Font5x7,5,7,32,127);
		update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size);
		if (start > 0) {
			glcd_draw_string_xy(13*6,0,"^");
		}
		if (start+4 < buf_size) {
			glcd_draw_string_xy(13*6,5*8,"v");
		}
		glcd_draw_char_xy(13*6,1*8,(start/4+1)/100%10+'0');
		glcd_draw_char_xy(13*6,2*8,(start/4+1)/10%10+'0');
		glcd_draw_char_xy(13*6,3*8,(start/4+1)%10+'0');
		glcd_write();
		/*
		start+=4;
		if (start > 24) start = 0;
		*/
		
		int reading = 0;
		not_scroll:
		reading = Keypad_1_GetButton();
		switch (reading) {
			case 7:
				if (start+4 < buf_size) start+=4;
				break;
			case 15:
				if (start > 0) start-=4;
				break;
			case 3:
				play_song(noteBuffer, accidentals, octaveBuffer, buf_size);
				break;
			case 0:
				for (int i = 0; i < 4; ++i) {
					glcd_invert_area(i*18, 0, 6, 8);
					glcd_write();
					CyDelay(200);
					int button = 7;
					while (button > 6) {
						button = keycode_to_note[Keypad_1_GetButton()];
					}
					noteBuffer[start+i] = button;
					update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size);
					glcd_invert_area(i*18+6, 0, 6, 8);
					glcd_write();
					CyDelay(200);
					button = 2;
					while (button > 1) {
						button = keycode_to_accidental[Keypad_1_GetButton()];
						if (button == 99) goto cancel_edit;
					}
					accidentals[start+i] = button;
					update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size);
					glcd_invert_area(i*18+12, 0, 6, 8);
					glcd_write();
					CyDelay(200);
					button = 10;
					while (button > 9) {
						button = keycode_to_octave[Keypad_1_GetButton()];
						if (button == 99) goto cancel_edit;
					}
					octaveBuffer[start+i] = button;
					update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size);
				}
				cancel_edit:
				break;
			case 1:
				glcd_clear();
				glcd_draw_string_xy(0,0,"Saving...");
				glcd_write();
				int fail = 0;
				fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)noteBuffer, (void*)rom_notes, SONG_SIZE*sizeof(int));
				fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)accidentals, (void*)rom_accidentals, SONG_SIZE*sizeof(int));
				fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)octaveBuffer, (void*)rom_octaves, SONG_SIZE*sizeof(int));
				if (fail) {
					glcd_draw_string_xy(0,8,"Failed!");
					glcd_write();
					CyDelay(1000);
				}
				else {
					glcd_draw_string_xy(0,8,"Success!");
					glcd_write();
					CyDelay(300);
				}
				break;
			default:
				goto not_scroll;
		}
		CyDelay(50);
	}
}