Added pitch bend feature to default instrument.
[cantaveria.git] / soundtest.c
blobbd957fad28c4f57735078524df3fe7f61d959d96
1 #include <stdio.h>
3 #include <input.h>
4 #include <graphics.h>
5 #include <console.h>
6 #include <transfer.h>
7 #include <seq.h>
8 #include <org.h>
10 void play(int note){
11 seq_instant(EV_NOTEON, 0, note, 0);
14 void stop(int note){
15 seq_instant(EV_NOTEOFF, 0, note, 0);
18 void bend(int amount){
19 seq_instant(EV_PITCHBEND, 0, 0, amount);
22 int bend_amount = 8192;
23 int bend_v = 0;
25 static void press(input in){
26 if(in.button == ESCAPE_KEY){
27 game_is_over();
30 console_printf("%s", input_str(in));
32 switch(in.button){
33 case LEFT_BUTTON: play(0); break;
34 case RIGHT_BUTTON: play(4); break;
35 case DOWN_BUTTON: play(2); break;
36 case FIRE_BUTTON: play(5); break;
37 case JUMP_BUTTON: play(7); break;
38 case SPECIAL_BUTTON: play(9); break;
39 case L_BUTTON: bend_v = -1; break;
40 case R_BUTTON: bend_v = 1; break;
41 default: break;
45 static void release(input in){
46 switch(in.button){
47 case LEFT_BUTTON: stop(0); break;
48 case RIGHT_BUTTON: stop(4); break;
49 case DOWN_BUTTON: stop(2); break;
50 case FIRE_BUTTON: stop(5); break;
51 case JUMP_BUTTON: stop(7); break;
52 case SPECIAL_BUTTON: stop(9); break;
53 case L_BUTTON: bend_v = 0; break;
54 case R_BUTTON: bend_v = 0; break;
55 default: break;
59 static void update(){
60 console_update();
62 bend_amount += bend_v;
63 if(bend_amount > 0x7f) bend_amount = 0x7f;
64 if(bend_amount < 0x00) bend_amount = 0x00;
65 if(bend_v != 0){
66 bend(bend_amount);
70 static void draw(){
74 void setup_inner(){
75 set_handler(update, draw, press, release);
76 console_clear();