Ejemplo n.º 1
0
//2ms Service Loop -- Call once every 2ms
void service_audio(){
	switch(_audio_state){
		case AUDIO_BEEPING:
			_audio_counter--;
			if (_audio_counter <= 0) {
				//End of this beep!
				audio_volume(0x00); //silence!
				if (_audio_num_beeps == 0) {
					//End of this beep sequence -- ALL DONE! =)					
					_audio_state = AUDIO_IDLE;
				}
				else {
					//start quiet period between beeps
					_audio_state = AUDIO_BETWEEN;
					_audio_counter = AUDIO_GAP_LENGTH;
				}
			}
			break;
		case AUDIO_BETWEEN:
			_audio_counter--;
			if (_audio_counter <= 0) {
				//End of gap
				_audio_beep();
			}
			break;
		case AUDIO_IDLE:
		default:
			audio_volume(0x00); //Silence!
			return;
	}
}
Ejemplo n.º 2
0
static int conf_action(int tok, int val)
{
    int sound = config_get_d(CONFIG_SOUND_VOLUME);
    int music = config_get_d(CONFIG_MUSIC_VOLUME);
    int mouse = MOUSE_RANGE_MAP(config_get_d(CONFIG_MOUSE_SENSE));
    int r = 1;

    audio_play(AUD_MENU, 1.0f);

    switch (tok)
    {
    case GUI_BACK:
        goto_state(&st_title);
        break;

    case CONF_VIDEO:
        goto_state(&st_conf_video);
        break;

    case CONF_PLAYER:
        goto_name(&st_conf, &st_conf, 1);
        break;

    case CONF_BALL:
        goto_state(&st_ball);
        break;

    case CONF_MOUSE_SENSE:
        config_set_d(CONFIG_MOUSE_SENSE, MOUSE_RANGE_UNMAP(val));

        gui_toggle(mouse_id[val]);
        gui_toggle(mouse_id[mouse]);
        break;

    case CONF_SOUND_VOLUME:
        config_set_d(CONFIG_SOUND_VOLUME, val);
        audio_volume(val, music);
        audio_play(AUD_BUMPM, 1.f);

        gui_toggle(sound_id[val]);
        gui_toggle(sound_id[sound]);
        break;

    case CONF_MUSIC_VOLUME:
        config_set_d(CONFIG_MUSIC_VOLUME, val);
        audio_volume(sound, val);
        audio_play(AUD_BUMPM, 1.f);

        gui_toggle(music_id[val]);
        gui_toggle(music_id[music]);

        break;
    }

    return r;
}
Ejemplo n.º 3
0
int main(void) {
	long vol = -1;
	printf("Ret %i\n", audio_volume(AUDIO_VOLUME_GET, &vol));
	printf("Master volume is %li\n", vol);

	vol = 100;
	printf("Ret %i\n", audio_volume(AUDIO_VOLUME_SET, &vol));

	return 0;
}
Ejemplo n.º 4
0
static int conf_action(int i)
{
    int s = config_get_d(CONFIG_SOUND_VOLUME);
    int m = config_get_d(CONFIG_MUSIC_VOLUME);
    int r = 1;

    audio_play(AUD_MENU, 1.0f);

    switch (i)
    {
    case CONF_BACK:
        goto_state(&st_title);
        break;

    case CONF_VIDEO:
        goto_state(&st_video);
        break;

    case CONF_LANG:
        goto_state(&st_lang);
        break;

    default:
        if (100 <= i && i <= 110)
        {
            int n = i - 100;

            config_set_d(CONFIG_SOUND_VOLUME, n);
            audio_volume(n, m);
            audio_play(AUD_BUMP, 1.f);

            gui_toggle(sound_id[n]);
            gui_toggle(sound_id[s]);
        }
        if (200 <= i && i <= 210)
        {
            int n = i - 200;

            config_set_d(CONFIG_MUSIC_VOLUME, n);
            audio_volume(s, n);
            audio_play(AUD_BUMP, 1.f);

            gui_toggle(music_id[n]);
            gui_toggle(music_id[m]);
        }
    }

    return r;
}
Ejemplo n.º 5
0
void init_ui(){
	//LED's are located at PF0 (Lower) and PF1 (Upper)
	PORTF.DIRSET = B8(00001111); //pins 0,1,2,3 to output	
	PORTF.PIN0CTRL = B8(01000000); //Invert the pin (needed to achieve correct PWM output polarity)
	PORTF.PIN1CTRL = B8(01000000); //Invert the pin (needed to achieve correct PWM output polarity)
	PORTF.PIN3CTRL = B8(01000000); //Invert the pin (needed to achieve correct PWM output polarity)
	TCF0.CTRLA = 0x07; //enable; div1024
	TCF0.CTRLB = B8(11110011); //All output channels enabled (A through D); Single-slope PWM
	TCF0.PER = 0x00FF; //Set the top of the counter to basically force 8 bit operation; we do this for speed when calling dimming functions in the future
	audio_volume(0x00);
	led_off(LED_0);
	led_off(LED_1);
	led_off(LED_3);			
}
Ejemplo n.º 6
0
//Internal function to actually start making noise
void _audio_beep(){
	_audio_num_beeps--;
	_audio_state = AUDIO_BEEPING;
	_audio_counter = AUDIO_BEEP_LENGTH;
	audio_volume(_audio_volume); //actually start making noise
}	
Ejemplo n.º 7
0
static int conf_action(int i)
{
    int w = config_get_d(CONFIG_WIDTH);
    int h = config_get_d(CONFIG_HEIGHT);
    int s = config_get_d(CONFIG_SOUND_VOLUME);
    int m = config_get_d(CONFIG_MUSIC_VOLUME);
    int r = 1;

    audio_play(AUD_MENU, 1.0f);

    switch (i)
    {
    case CONF_FULL:
        goto_state(&st_null);
        r = video_mode(1, w, h);
        goto_state(&st_conf);
        break;

    case CONF_WIN:
        goto_state(&st_null);
        r = video_mode(0, w, h);
        goto_state(&st_conf);
        break;

    case CONF_TEXHI:
        goto_state(&st_null);
        config_set_d(CONFIG_TEXTURES, 1);
        goto_state(&st_conf);
        break;

    case CONF_TEXLO:
        goto_state(&st_null);
        config_set_d(CONFIG_TEXTURES, 2);
        goto_state(&st_conf);
        break;

    case CONF_SHDON:
        goto_state(&st_null);
        config_set_d(CONFIG_SHADOW, 1);
        goto_state(&st_conf);
        break;

    case CONF_SHDOF:
        goto_state(&st_null);
        config_set_d(CONFIG_SHADOW, 0);
        goto_state(&st_conf);
        break;

    case CONF_BACK:
        goto_state(&st_title);
        break;

    case CONF_RESOL:
        goto_state(&st_resol);
        break;

    default:
        if (100 <= i && i <= 110)
        {
            int n = i - 100;

            config_set_d(CONFIG_SOUND_VOLUME, n);
            audio_volume(n, m);
            audio_play(AUD_BUMP, 1.f);

            gui_toggle(sound_id[n]);
            gui_toggle(sound_id[s]);
        }
        if (200 <= i && i <= 210)
        {
            int n = i - 200;

            config_set_d(CONFIG_MUSIC_VOLUME, n);
            audio_volume(s, n);
            audio_play(AUD_BUMP, 1.f);

            gui_toggle(music_id[n]);
            gui_toggle(music_id[m]);
        }
    }

    return r;
}