From 766af7979b93201ce6babafe3cc684f75f3ce6d1 Mon Sep 17 00:00:00 2001 From: angel Date: Wed, 14 Feb 2007 08:27:58 +0000 Subject: [PATCH] Added attack support to the compiler and event converters. git-svn-id: file:///home/angel/tmp/svn-triptico/ahxm/trunk@6015 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- ahxm.h | 11 +++++++++++ compiler.l | 1 + compiler.y | 17 ++++++++++++++++- midi_song.c | 1 + ss_song.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ahxm.h b/ahxm.h index a946900..870f488 100644 --- a/ahxm.h +++ b/ahxm.h @@ -148,6 +148,7 @@ typedef enum SONG_EV_MEASURE, SONG_EV_SS_SUSTAIN, + SONG_EV_SS_ATTACK, SONG_EV_SS_VIBRATO, SONG_EV_SS_PORTAMENTO, SONG_EV_SS_CHANNEL, @@ -272,6 +273,15 @@ struct song_ev_ss_sustain double sustain; /* sustain time (in msecs) */ }; +struct song_ev_ss_attack +{ + song_ev_type type; /* SONG_EV_SS_ATTACK */ + double time; + int trk_id; + int event_id; + double attack; /* attack time (in msecs) */ +}; + struct song_ev_ss_vibrato { song_ev_type type; /* SONG_EV_SS_VIBRATO */ @@ -385,6 +395,7 @@ union song_ev struct song_ev_ss_print_wave_tempo ss_print_wave_tempo; struct song_ev_ss_sustain ss_sustain; + struct song_ev_ss_attack ss_attack; struct song_ev_ss_vibrato ss_vibrato; struct song_ev_ss_portamento ss_portamento; struct song_ev_ss_channel ss_channel; diff --git a/compiler.l b/compiler.l index 489f622..249cb4d 100644 --- a/compiler.l +++ b/compiler.l @@ -228,6 +228,7 @@ ALTSTR A[-&#]* wav { return(SS_WAV); } pat { return(SS_PAT); } sustain { return(SS_SUSTAIN); } +attack { return(SS_ATTACK); } vibrato { return(SS_VIBRATO); } portamento { return(SS_PORTAMENTO); } channel { return(SS_CHANNEL); } diff --git a/compiler.y b/compiler.y index e1f1ae4..c1fcc9e 100644 --- a/compiler.y +++ b/compiler.y @@ -558,6 +558,17 @@ static void add_ss_sustain_event(double sustain) } +static void add_ss_attack_event(double attack) +{ + union song_ev e; + + e.ss_attack.trk_id = track; + e.ss_attack.attack = attack; + + add_song_ev(SONG_EV_SS_ATTACK, cur_time, &e); +} + + static void add_ss_vibrato_event(double depth, double freq) { union song_ev e; @@ -760,7 +771,7 @@ static void init_track(void) %token XC_MSECS %token SS_SEP SS_WAV SS_LOOP_WAV SS_PAT -%token SS_SUSTAIN SS_VIBRATO SS_PORTAMENTO SS_CHANNEL SS_VOL +%token SS_SUSTAIN SS_ATTACK SS_VIBRATO SS_PORTAMENTO SS_CHANNEL SS_VOL %token SS_EFF_DELAY SS_EFF_ECHO SS_EFF_COMB SS_EFF_ALLPASS SS_EFF_FLANGER %token SS_EFF_WOBBLE SS_EFF_SQWOBBLE SS_EFF_HFWOBBLE @@ -1052,6 +1063,10 @@ xc_cmd: /* sets sustain */ add_ss_sustain_event($2); } + | SS_ATTACK XC_MSECS { + /* sets attack */ + add_ss_attack_event($2); + } | SS_VIBRATO XC_MSECS number { /* sets vibrato */ add_ss_vibrato_event($2, $3); diff --git a/midi_song.c b/midi_song.c index 605b7dd..756363e 100644 --- a/midi_song.c +++ b/midi_song.c @@ -265,6 +265,7 @@ static void midi_song_convert_events(void) case SONG_EV_SS_WAV: case SONG_EV_SS_PAT: case SONG_EV_SS_SUSTAIN: + case SONG_EV_SS_ATTACK: case SONG_EV_SS_VIBRATO: case SONG_EV_SS_PORTAMENTO: case SONG_EV_SS_CHANNEL: diff --git a/ss_song.c b/ss_song.c index 61aae87..8584ef5 100644 --- a/ss_song.c +++ b/ss_song.c @@ -73,6 +73,15 @@ struct ss_ev_ss_sustain double sustain; /* sustain time (in frames) */ }; +struct ss_ev_ss_attack +{ + song_ev_type type; /* SONG_EV_SS_ATTACK */ + int frame; + int trk_id; + int event_id; + double attack; /* attack time (in frames) */ +}; + struct ss_ev_ss_vibrato { song_ev_type type; /* SONG_EV_SS_VIBRATO */ @@ -408,6 +417,13 @@ static void ss_song_convert_events(int * n_channels) add_ss_ev(&sse); break; + case SONG_EV_SS_ATTACK: + + sse.ss_attack.attack = e->ss_attack.attack; + + add_ss_ev(&sse); + break; + case SONG_EV_SS_VIBRATO: sse.ss_vibrato.vib_depth = e->ss_vibrato.vib_depth; @@ -534,6 +550,12 @@ static void ss_song_trace_events(void) printf("SUSTAIN:%lf", e->ss_sustain.sustain); break; + case SONG_EV_SS_ATTACK: + + printf("SONG_EV_SS_ATTACK "); + printf("ATTACK:%lf", e->ss_attack.attack); + break; + case SONG_EV_SS_VIBRATO: printf("SONG_EV_SS_VIBRATO "); @@ -793,6 +815,12 @@ static union ss_ev * process_this_frame_events(union ss_ev * e, int skip_frames) break; + case SONG_EV_SS_ATTACK: + + ss_ins_set_attack(i, e->ss_attack.attack); + + break; + case SONG_EV_SS_VIBRATO: ss_ins_set_vibrato(i, e->ss_vibrato.vib_depth, -- 2.11.4.GIT