예제 #1
0
static void vis_oscilloscope(void)
{
	if (_vis_virgin) {
		vgamem_ovl_alloc(&vis_overlay);
		_vis_virgin = 0;
	}
	_draw_vis_box();
	song_lock_audio();
	if (status.vis_style == VIS_MONOSCOPE) {
		if (audio_output_bits == 16) {
			draw_sample_data_rect_16(&vis_overlay,audio_buffer,
					audio_buffer_samples,
					audio_output_channels,1);
		} else {
			draw_sample_data_rect_8(&vis_overlay,(void*)audio_buffer,
					audio_buffer_samples,
					audio_output_channels,1);
		}
	} else if (audio_output_bits == 16) {
		draw_sample_data_rect_16(&vis_overlay,audio_buffer,audio_buffer_samples,
					audio_output_channels,audio_output_channels);
	} else {
		draw_sample_data_rect_8(&vis_overlay,(void *)audio_buffer,audio_buffer_samples,
					audio_output_channels,audio_output_channels);
	}
	song_unlock_audio();
}
예제 #2
0
static void vis_fft(void)
{
	int i, y;
	/*this is the size of vis_overlay.width*/
	unsigned char outfft[120];

	if (_vis_virgin) {
		vgamem_ovl_alloc(&vis_overlay);
		_vis_virgin = 0;
	}
	_draw_vis_box();
	song_lock_audio();

	vgamem_ovl_clear(&vis_overlay,0);
	_get_columns_from_fft(outfft,current_fft_data);
	for (i = 0; i < 120; i++) {
		y = outfft[i];
		/*reduce range */
		y >>= 3;
		if (y > 15) y = 15;
		if (y > 0) {
		       vgamem_ovl_drawline(&vis_overlay,i,15-y,i,15,5);
		}
	}
	vgamem_ovl_apply(&vis_overlay);

	song_unlock_audio();
}
예제 #3
0
void sample_toggle_quality(song_sample_t * sample, int convert_data)
{
	signed char *odata;

	song_lock_audio();

	// stop playing the sample because we'll be reallocating and/or changing lengths
	csf_stop_sample(current_song, sample);

	sample->flags ^= CHN_16BIT;

	status.flags |= SONG_NEEDS_SAVE;
	if (convert_data) {
		odata = csf_allocate_sample(sample->length
			* ((sample->flags & CHN_16BIT) ? 2 : 1)
			* ((sample->flags & CHN_STEREO) ? 2 : 1));
		if (sample->flags & CHN_16BIT) {
			_quality_convert_8to16(sample->data, (signed short *) odata,
				sample->length * ((sample->flags & CHN_STEREO) ? 2 : 1));
		} else {
			_quality_convert_16to8((signed short *) sample->data, odata,
				sample->length * ((sample->flags & CHN_STEREO) ? 2 : 1));
		}
		csf_free_sample(sample->data);
		sample->data = odata;
	} else {
		if (sample->flags & CHN_16BIT) {
			sample->length >>= 1;
			sample->loop_start >>= 1;
			sample->loop_end >>= 1;
			sample->sustain_start >>= 1;
			sample->sustain_end >>= 1;
		} else {
예제 #4
0
void sample_reverse(song_sample_t * sample)
{
	unsigned long tmp;

	song_lock_audio();
	status.flags |= SONG_NEEDS_SAVE;

	if (sample->flags & CHN_STEREO) {
		if (sample->flags & CHN_16BIT)
			_reverse_32((signed int *)sample->data, sample->length);
		else
			_reverse_16((signed short *) sample->data, sample->length);
	} else {
		if (sample->flags & CHN_16BIT)
			_reverse_16((signed short *) sample->data, sample->length);
		else
			_reverse_8(sample->data, sample->length);
	}

	tmp = sample->length - sample->loop_start;
	sample->loop_start = sample->length - sample->loop_end;
	sample->loop_end = tmp;

	tmp = sample->length - sample->sustain_start;
	sample->sustain_start = sample->length - sample->sustain_end;
	sample->sustain_end = tmp;

	song_unlock_audio();
}
예제 #5
0
void sample_sign_convert(song_sample_t * sample)
{
	song_lock_audio();
	status.flags |= SONG_NEEDS_SAVE;
	if (sample->flags & CHN_16BIT)
		_sign_convert_16((signed short *) sample->data,
			sample->length * ((sample->flags & CHN_STEREO) ? 2 : 1));
	else
		_sign_convert_8(sample->data, sample->length * ((sample->flags & CHN_STEREO) ? 2 : 1));
	song_unlock_audio();
}
예제 #6
0
void cfg_load_midi(cfg_file_t *cfg)
{
        midi_config_t *md, *mc;
        char buf[17], buf2[33];
        int i;

        CFG_GET_MI(flags, MIDI_TICK_QUANTIZE | MIDI_RECORD_NOTEOFF
                | MIDI_RECORD_VELOCITY | MIDI_RECORD_AFTERTOUCH
                | MIDI_PITCHBEND);
        CFG_GET_MI(pitch_depth, 12);
        CFG_GET_MI(amplification, 100);
        CFG_GET_MI(c5note, 60);

        song_lock_audio();
        md = &default_midi_config;
        cfg_get_string(cfg,"MIDI","start", md->start, 31, "FF");
        cfg_get_string(cfg,"MIDI","stop", md->stop, 31, "FC");
        cfg_get_string(cfg,"MIDI","tick", md->tick, 31, "");
        cfg_get_string(cfg,"MIDI","note_on", md->note_on, 31, "9c n v");
        cfg_get_string(cfg,"MIDI","note_off", md->note_off, 31, "9c n 0");
        cfg_get_string(cfg,"MIDI","set_volume", md->set_volume, 31, "");
        cfg_get_string(cfg,"MIDI","set_panning", md->set_panning, 31, "");
        cfg_get_string(cfg,"MIDI","set_bank", md->set_bank, 31, "");
        cfg_get_string(cfg,"MIDI","set_program", md->set_program, 31, "Cc p");
        for (i = 0; i < 16; i++) {
                snprintf(buf, 16, "SF%X", i);
                cfg_get_string(cfg, "MIDI", buf, md->sfx[i], 31,
                                i == 0 ? "F0F000z" : "");
        }

        for (i = 0; i < 128; i++) {
                snprintf(buf, 16, "Z%02X", i + 0x80);
                if (i < 16)
                        snprintf(buf2, 32, "F0F001%02x", i * 8);
                else
                        buf2[0] = '\0';
                cfg_get_string(cfg, "MIDI", buf, md->zxx[i], 31, buf2);
        }

        mc = &current_song->midi_config;
        memcpy(mc, md, sizeof(midi_config_t));


        song_unlock_audio();
}
예제 #7
0
/* this does the lines for playing samples */
static void _draw_sample_play_marks(struct vgamem_overlay *r, song_sample_t * sample)
{
        int n, x, y;
        int c;
        song_voice_t *channel;
        unsigned int *channel_list;

        if (song_get_mode() == MODE_STOPPED)
                return;

        song_lock_audio();

        n = song_get_mix_state(&channel_list);
        while (n--) {
                channel = song_get_mix_channel(channel_list[n]);
                if (channel->current_sample_data != sample->data)
                        continue;
                if (!channel->final_volume) continue;
                c = (channel->flags & (CHN_KEYOFF | CHN_NOTEFADE)) ? SAMPLE_BGMARK_COLOR : SAMPLE_MARK_COLOR;
                x = channel->position * (r->width - 1) / sample->length;
                if (x >= r->width) {
                        /* this does, in fact, happen :( */
                        continue;
                }
                y = 0;
                do {
                        /* unrolled 8 times */
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                        vgamem_ovl_drawpixel(r, x, y++, c);
                } while (y < r->height);
        }

        song_unlock_audio();
}
예제 #8
0
void cfg_save_midi(cfg_file_t *cfg)
{
        struct cfg_section *c;
        struct midi_provider *p;
        struct midi_port *q;
        midi_config_t *md, *mc;
        char buf[33];
        char *ss;
        int i, j;

        CFG_SET_MI(flags);
        CFG_SET_MI(pitch_depth);
        CFG_SET_MI(amplification);
        CFG_SET_MI(c5note);

        song_lock_audio();
        md = &default_midi_config;

        /* overwrite default */
        mc = &current_song->midi_config;
        memcpy(md, mc, sizeof(midi_config_t));

        cfg_set_string(cfg,"MIDI","start", md->start);
        cfg_set_string(cfg,"MIDI","stop", md->stop);
        cfg_set_string(cfg,"MIDI","tick", md->tick);
        cfg_set_string(cfg,"MIDI","note_on", md->note_on);
        cfg_set_string(cfg,"MIDI","note_off", md->note_off);
        cfg_set_string(cfg,"MIDI","set_volume", md->set_volume);
        cfg_set_string(cfg,"MIDI","set_panning", md->set_panning);
        cfg_set_string(cfg,"MIDI","set_bank", md->set_bank);
        cfg_set_string(cfg,"MIDI","set_program", md->set_program);
        for (i = 0; i < 16; i++) {
                snprintf(buf, 32, "SF%X", i);
                cfg_set_string(cfg, "MIDI", buf, md->sfx[i]);
        }
        for (i = 0; i < 128; i++) {
                snprintf(buf, 32, "Z%02X", i + 0x80);
                cfg_set_string(cfg, "MIDI", buf, md->zxx[i]);
        }
        song_unlock_audio();

        /* write out only enabled midi ports */
        i = 1;
        SDL_mutexP(midi_mutex);
        q = NULL;
        for (p = port_providers; p; p = p->next) {
                while (midi_port_foreach(p, &q)) {
                        ss = q->name;
                        if (!ss) continue;
                        while (isspace(*ss)) ss++;
                        if (!*ss) continue;
                        if (!q->io) continue;

                        snprintf(buf, 32, "MIDI Port %d", i); i++;
                        cfg_set_string(cfg, buf, "name", ss);
                        ss = p->name;
                        if (ss) {
                                while (isspace(*ss)) ss++;
                                if (*ss) {
                                        cfg_set_string(cfg, buf, "provider", ss);
                                }
                        }
                        cfg_set_number(cfg, buf, "input", q->io & MIDI_INPUT ? 1 : 0);
                        cfg_set_number(cfg, buf, "output", q->io & MIDI_OUTPUT ? 1 : 0);
                }
        }
        //TODO: Save number of MIDI-IP ports
        SDL_mutexV(midi_mutex);

        /* delete other MIDI port sections */
        for (c = cfg->sections; c; c = c->next) {
                j = -1;
                sscanf(c->name, "MIDI Port %d", &j);
                if (j < i) continue;
                c->omit = 1;
        }

}