Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Front/Front.cpp@33:e7635c8a58a8, 2020-05-26 (annotated)
- Committer:
- lukeocarwright
- Date:
- Tue May 26 14:32:06 2020 +0000
- Revision:
- 33:e7635c8a58a8
- Parent:
- 31:cfdb014ff086
Final Project submission
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lukeocarwright | 7:33cb5f2db1ee | 1 | #include "mbed.h" |
lukeocarwright | 7:33cb5f2db1ee | 2 | #include "Front.h" |
lukeocarwright | 7:33cb5f2db1ee | 3 | |
lukeocarwright | 14:9cfe0041cc4e | 4 | //Objects----------------------------------------------------------------------- |
lukeocarwright | 14:9cfe0041cc4e | 5 | Sound sound; |
lukeocarwright | 18:204cd747b54a | 6 | Envelope envelope; |
lukeocarwright | 24:c3bb1b0b2207 | 7 | Filter filter; |
lukeocarwright | 14:9cfe0041cc4e | 8 | |
lukeocarwright | 14:9cfe0041cc4e | 9 | //Sprites----------------------------------------------------------------------- |
lukeocarwright | 19:08862f49cd9e | 10 | const int fader[35][5] = { //Fader Sprite |
lukeocarwright | 7:33cb5f2db1ee | 11 | { 1,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 12 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 13 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 14 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 15 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 16 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 17 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 18 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 19 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 20 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 21 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 22 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 23 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 24 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 25 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 26 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 27 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 28 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 29 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 30 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 31 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 32 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 33 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 34 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 35 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 36 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 37 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 38 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 39 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 40 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 41 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 42 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 43 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 44 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 45 | { 1,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 46 | }; |
lukeocarwright | 7:33cb5f2db1ee | 47 | |
lukeocarwright | 14:9cfe0041cc4e | 48 | const int sin_wav[6][28] = {//sub 1 sin sprite |
lukeocarwright | 7:33cb5f2db1ee | 49 | { 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 50 | { 0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 51 | { 1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 52 | { 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 53 | { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 54 | { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 55 | }; |
lukeocarwright | 14:9cfe0041cc4e | 56 | const int tri_wav[6][28] = {//sub 2 tri sprite |
lukeocarwright | 7:33cb5f2db1ee | 57 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 58 | { 0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 59 | { 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 60 | { 1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 61 | { 0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 62 | { 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 63 | }; |
lukeocarwright | 14:9cfe0041cc4e | 64 | const int square_wav[6][28] = {//sub 3 sqr sprite |
lukeocarwright | 7:33cb5f2db1ee | 65 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 66 | { 1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 67 | { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 68 | { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 69 | { 0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 70 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 71 | }; |
lukeocarwright | 25:f230af268e8b | 72 | |
lukeocarwright | 25:f230af268e8b | 73 | const int Low_pass[19][29]= {//LPF plot |
lukeocarwright | 25:f230af268e8b | 74 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 75 | { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 76 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 77 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 78 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 79 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 80 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 81 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 82 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 83 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 84 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 85 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 86 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 87 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 88 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 89 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 90 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 91 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 92 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0 }, |
lukeocarwright | 25:f230af268e8b | 93 | }; |
lukeocarwright | 25:f230af268e8b | 94 | |
lukeocarwright | 25:f230af268e8b | 95 | const int High_pass[19][29]= {//HPF plot |
lukeocarwright | 25:f230af268e8b | 96 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 97 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, |
lukeocarwright | 25:f230af268e8b | 98 | { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 99 | { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 100 | { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 101 | { 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 102 | { 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 103 | { 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 104 | { 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 105 | { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 106 | { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 107 | { 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 108 | { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 109 | { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 110 | { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 111 | { 0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 112 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 113 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 114 | { 0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 115 | }; |
lukeocarwright | 25:f230af268e8b | 116 | |
lukeocarwright | 25:f230af268e8b | 117 | const int Band_pass[19][29]= {//BPF plot |
lukeocarwright | 25:f230af268e8b | 118 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 119 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 120 | { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 121 | { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 122 | { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 123 | { 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 124 | { 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 125 | { 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 126 | { 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 127 | { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 128 | { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 129 | { 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 130 | { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 131 | { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 132 | { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 133 | { 0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 134 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 135 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 }, |
lukeocarwright | 25:f230af268e8b | 136 | { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 }, |
lukeocarwright | 25:f230af268e8b | 137 | }; |
lukeocarwright | 25:f230af268e8b | 138 | |
lukeocarwright | 18:204cd747b54a | 139 | //Gloabal Variables |
lukeocarwright | 19:08862f49cd9e | 140 | volatile int g_isr_flag; //used for sound generation |
lukeocarwright | 24:c3bb1b0b2207 | 141 | volatile extern int silent_flag; //used for note release |
lukeocarwright | 19:08862f49cd9e | 142 | |
lukeocarwright | 14:9cfe0041cc4e | 143 | |
lukeocarwright | 7:33cb5f2db1ee | 144 | //constructor/destructor |
lukeocarwright | 7:33cb5f2db1ee | 145 | Front::Front() |
lukeocarwright | 7:33cb5f2db1ee | 146 | { |
lukeocarwright | 7:33cb5f2db1ee | 147 | } |
lukeocarwright | 7:33cb5f2db1ee | 148 | Front::~Front() |
lukeocarwright | 7:33cb5f2db1ee | 149 | { |
lukeocarwright | 7:33cb5f2db1ee | 150 | } |
lukeocarwright | 7:33cb5f2db1ee | 151 | //PUBLIC------------------------------------------------------------------------ |
lukeocarwright | 8:f305ea78b2b1 | 152 | |
lukeocarwright | 8:f305ea78b2b1 | 153 | void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu) |
lukeocarwright | 18:204cd747b54a | 154 | { |
lukeocarwright | 25:f230af268e8b | 155 | frontsetup(lcd, pad, submenu,0, true); //Initialises front pannel display |
lukeocarwright | 30:08cc4ec58d07 | 156 | frequency=frequency_convert(pad,oct); //collects initial frequency |
lukeocarwright | 30:08cc4ec58d07 | 157 | release_flag=silent_flag=0; //Flags setup |
lukeocarwright | 30:08cc4ec58d07 | 158 | used=menuflag=1; //initialises vairables |
lukeocarwright | 25:f230af268e8b | 159 | filter_type=envelope_in=0; |
lukeocarwright | 19:08862f49cd9e | 160 | a=d=s=r=17; //starting adsr values (1->35) |
lukeocarwright | 19:08862f49cd9e | 161 | noteon=false; |
lukeocarwright | 30:08cc4ec58d07 | 162 | oct=3; //starting octave |
lukeocarwright | 19:08862f49cd9e | 163 | #ifdef CSV |
lukeocarwright | 19:08862f49cd9e | 164 | itterator=0; //sets itterator for CSV OUTPUT |
lukeocarwright | 19:08862f49cd9e | 165 | #endif |
lukeocarwright | 18:204cd747b54a | 166 | |
lukeocarwright | 8:f305ea78b2b1 | 167 | while (menuflag==1) { |
lukeocarwright | 18:204cd747b54a | 168 | #ifdef SLOW_TIME |
lukeocarwright | 30:08cc4ec58d07 | 169 | print_SLOWTIME_out(out,noteon,a,d,s,r,release_flag,silent_flag); //debug terminal print function |
lukeocarwright | 18:204cd747b54a | 170 | #endif |
lukeocarwright | 30:08cc4ec58d07 | 171 | if (noteon==true && g_isr_flag == 1) { //isr triggered and note on |
lukeocarwright | 31:cfdb014ff086 | 172 | pad.write_u16(out); //writes Output in uns short format |
lukeocarwright | 27:da783f414f67 | 173 | envelope_in=(sound.sound_main(false,submenu,frequency)-32767); //int around 0 |
lukeocarwright | 27:da783f414f67 | 174 | envelope_in=filter.filter_run(envelope_in,filter_type,false); |
lukeocarwright | 31:cfdb014ff086 | 175 | if (release_flag==0) { //Note still on |
lukeocarwright | 27:da783f414f67 | 176 | out=(envelope.env_in(a,d,s,r,envelope_in,false));//Uint around 32767 |
lukeocarwright | 31:cfdb014ff086 | 177 | } else { //Note off |
lukeocarwright | 31:cfdb014ff086 | 178 | out=envelope.release(s,r,envelope_in,false); //release rubnthrough |
lukeocarwright | 31:cfdb014ff086 | 179 | if (silent_flag==1) { //release transient finished |
lukeocarwright | 31:cfdb014ff086 | 180 | release_flag=0; //resets variables |
lukeocarwright | 19:08862f49cd9e | 181 | silent_flag=0; |
lukeocarwright | 19:08862f49cd9e | 182 | noteon=false; |
lukeocarwright | 31:cfdb014ff086 | 183 | out=envelope.env_in(a,d,s,r,out,true); //initialises |
lukeocarwright | 19:08862f49cd9e | 184 | out=0; |
lukeocarwright | 19:08862f49cd9e | 185 | } |
lukeocarwright | 19:08862f49cd9e | 186 | } |
lukeocarwright | 31:cfdb014ff086 | 187 | g_isr_flag=0; //resets ISR flag |
lukeocarwright | 31:cfdb014ff086 | 188 | #ifdef CSV //generates CSV out |
lukeocarwright | 19:08862f49cd9e | 189 | printf("%d,%d\n",itterator,out); |
lukeocarwright | 19:08862f49cd9e | 190 | itterator++; |
lukeocarwright | 18:204cd747b54a | 191 | #endif |
lukeocarwright | 18:204cd747b54a | 192 | } |
lukeocarwright | 31:cfdb014ff086 | 193 | dir=pad.get_direction(); //checks joystick |
lukeocarwright | 13:27300c533dd1 | 194 | if (dir!=dir_1) { |
lukeocarwright | 30:08cc4ec58d07 | 195 | //printf("dir =%d\n",dir); //debug |
lukeocarwright | 31:cfdb014ff086 | 196 | switch (dir) { |
lukeocarwright | 31:cfdb014ff086 | 197 | case 3: |
lukeocarwright | 31:cfdb014ff086 | 198 | used=fader_select(used,1); break; //itterates Fader (R) |
lukeocarwright | 31:cfdb014ff086 | 199 | case 7: |
lukeocarwright | 31:cfdb014ff086 | 200 | used=fader_select(used,-1); break; //itterates fader(L) |
lukeocarwright | 31:cfdb014ff086 | 201 | case 1: |
lukeocarwright | 31:cfdb014ff086 | 202 | if (used==1) { |
lukeocarwright | 31:cfdb014ff086 | 203 | a=incrament_adsr(used,a,1); //Attack up |
lukeocarwright | 31:cfdb014ff086 | 204 | } |
lukeocarwright | 31:cfdb014ff086 | 205 | if (used==2) { |
lukeocarwright | 31:cfdb014ff086 | 206 | d=incrament_adsr(used,d,1); //Decay up |
lukeocarwright | 31:cfdb014ff086 | 207 | } |
lukeocarwright | 31:cfdb014ff086 | 208 | if (used==3) { |
lukeocarwright | 31:cfdb014ff086 | 209 | s=incrament_adsr(used,s,1); //Sustain Up |
lukeocarwright | 31:cfdb014ff086 | 210 | } |
lukeocarwright | 31:cfdb014ff086 | 211 | if (used==4) { |
lukeocarwright | 31:cfdb014ff086 | 212 | r=incrament_adsr(used,r,1); //Release Up |
lukeocarwright | 31:cfdb014ff086 | 213 | } |
lukeocarwright | 31:cfdb014ff086 | 214 | if (used==5) { //Filter UP |
lukeocarwright | 31:cfdb014ff086 | 215 | filter_type=incrament_adsr(used,filter_type,-1); |
lukeocarwright | 31:cfdb014ff086 | 216 | //printf("FILTER_TYPE=%d\n",filter_type); |
lukeocarwright | 31:cfdb014ff086 | 217 | } |
lukeocarwright | 31:cfdb014ff086 | 218 | break; |
lukeocarwright | 31:cfdb014ff086 | 219 | case 5: |
lukeocarwright | 31:cfdb014ff086 | 220 | if (used==1) { |
lukeocarwright | 31:cfdb014ff086 | 221 | a=incrament_adsr(used,a,-1); //Attack Down |
lukeocarwright | 31:cfdb014ff086 | 222 | } |
lukeocarwright | 31:cfdb014ff086 | 223 | if (used==2) { |
lukeocarwright | 31:cfdb014ff086 | 224 | d=incrament_adsr(used,d,-1); //Decay Down |
lukeocarwright | 31:cfdb014ff086 | 225 | } |
lukeocarwright | 31:cfdb014ff086 | 226 | if (used==3) { |
lukeocarwright | 31:cfdb014ff086 | 227 | s=incrament_adsr(used,s,-1); //Sustain Down |
lukeocarwright | 31:cfdb014ff086 | 228 | } |
lukeocarwright | 31:cfdb014ff086 | 229 | if (used==4) { |
lukeocarwright | 31:cfdb014ff086 | 230 | r=incrament_adsr(used,r,-1); //Release Down |
lukeocarwright | 31:cfdb014ff086 | 231 | } |
lukeocarwright | 31:cfdb014ff086 | 232 | if (used==5) { //Filter Down |
lukeocarwright | 31:cfdb014ff086 | 233 | filter_type=incrament_adsr(used,filter_type,1); |
lukeocarwright | 31:cfdb014ff086 | 234 | //printf("FILTER_TYPE=%d\n",filter_type); |
lukeocarwright | 31:cfdb014ff086 | 235 | } |
lukeocarwright | 31:cfdb014ff086 | 236 | break; |
lukeocarwright | 13:27300c533dd1 | 237 | } |
lukeocarwright | 31:cfdb014ff086 | 238 | frontsetup(lcd,pad,submenu,filter_type,false); //reprints Front Panel |
lukeocarwright | 31:cfdb014ff086 | 239 | printsliders(lcd,a,d,s,r,used); //Prints Sliders |
lukeocarwright | 31:cfdb014ff086 | 240 | wait_ms(100); //Debounce |
lukeocarwright | 18:204cd747b54a | 241 | } //END if DIR |
lukeocarwright | 18:204cd747b54a | 242 | if ( pad.A_pressed()) { //NOTE ON |
lukeocarwright | 31:cfdb014ff086 | 243 | //printf("NOTE_ON\n"); |
lukeocarwright | 18:204cd747b54a | 244 | noteon=true; |
lukeocarwright | 31:cfdb014ff086 | 245 | out=envelope.env_in(a,d,s,r,out,true); //Initiialises |
lukeocarwright | 31:cfdb014ff086 | 246 | frequency=frequency_convert(pad,oct); //Checks Frequnecy |
lukeocarwright | 18:204cd747b54a | 247 | } |
lukeocarwright | 18:204cd747b54a | 248 | if ( pad.B_pressed()) { //NOTE OFF |
lukeocarwright | 31:cfdb014ff086 | 249 | release_flag=1; //Begins release |
lukeocarwright | 31:cfdb014ff086 | 250 | envelope_in=envelope.release(s,r,envelope_in,true); //initialises |
lukeocarwright | 19:08862f49cd9e | 251 | pad.reset_buttons(); |
lukeocarwright | 18:204cd747b54a | 252 | } |
lukeocarwright | 31:cfdb014ff086 | 253 | if ( pad.X_pressed()) { //Down Octave |
lukeocarwright | 28:eb0f12304a45 | 254 | oct--; |
lukeocarwright | 31:cfdb014ff086 | 255 | if (oct<0) { //Min Value |
lukeocarwright | 31:cfdb014ff086 | 256 | oct++; |
lukeocarwright | 31:cfdb014ff086 | 257 | } |
lukeocarwright | 31:cfdb014ff086 | 258 | //printf("OCTAVE %d\n",oct); |
lukeocarwright | 27:da783f414f67 | 259 | pad.reset_buttons(); |
lukeocarwright | 27:da783f414f67 | 260 | } |
lukeocarwright | 31:cfdb014ff086 | 261 | if ( pad.Y_pressed()) { //Octave Up |
lukeocarwright | 28:eb0f12304a45 | 262 | oct++; |
lukeocarwright | 31:cfdb014ff086 | 263 | if (oct>5) { //Max Value |
lukeocarwright | 31:cfdb014ff086 | 264 | oct--; |
lukeocarwright | 31:cfdb014ff086 | 265 | } |
lukeocarwright | 31:cfdb014ff086 | 266 | //printf("OCTAVE %d\n",oct); |
lukeocarwright | 27:da783f414f67 | 267 | pad.reset_buttons(); |
lukeocarwright | 27:da783f414f67 | 268 | } |
lukeocarwright | 18:204cd747b54a | 269 | |
lukeocarwright | 31:cfdb014ff086 | 270 | if (pad.start_pressed()) { //Main Menu Select |
lukeocarwright | 31:cfdb014ff086 | 271 | //printf("Main selected\n"); //debug |
lukeocarwright | 18:204cd747b54a | 272 | noteon=false; |
lukeocarwright | 31:cfdb014ff086 | 273 | menuflag=0; //sets flag to exit |
lukeocarwright | 29:207111ffd6e6 | 274 | break; |
lukeocarwright | 8:f305ea78b2b1 | 275 | } |
lukeocarwright | 13:27300c533dd1 | 276 | dir=dir_1; |
lukeocarwright | 19:08862f49cd9e | 277 | sleep(); //puts sleep until ISR wakes up |
lukeocarwright | 19:08862f49cd9e | 278 | } |
lukeocarwright | 8:f305ea78b2b1 | 279 | } |
lukeocarwright | 8:f305ea78b2b1 | 280 | |
lukeocarwright | 31:cfdb014ff086 | 281 | |
lukeocarwright | 8:f305ea78b2b1 | 282 | //PRIVATE----------------------------------------------------------------------- |
lukeocarwright | 8:f305ea78b2b1 | 283 | |
lukeocarwright | 25:f230af268e8b | 284 | void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, int filter_type, bool initial) |
lukeocarwright | 7:33cb5f2db1ee | 285 | { |
lukeocarwright | 31:cfdb014ff086 | 286 | if (initial==true) { //intial Setup |
lukeocarwright | 31:cfdb014ff086 | 287 | printsliders(lcd,17,17,17,17,1); |
lukeocarwright | 31:cfdb014ff086 | 288 | initialise(pad,lcd,submenu); //Initialises functions |
lukeocarwright | 25:f230af268e8b | 289 | |
lukeocarwright | 13:27300c533dd1 | 290 | } |
lukeocarwright | 31:cfdb014ff086 | 291 | lcd.clear(); //Draws Front Pannel |
lukeocarwright | 7:33cb5f2db1ee | 292 | lcd.printString("A D S R",3,5); |
lukeocarwright | 7:33cb5f2db1ee | 293 | printfader(lcd,3,3); |
lukeocarwright | 7:33cb5f2db1ee | 294 | printfader(lcd,15,3); |
lukeocarwright | 7:33cb5f2db1ee | 295 | printfader(lcd,27,3); |
lukeocarwright | 7:33cb5f2db1ee | 296 | printfader(lcd,39,3); |
lukeocarwright | 7:33cb5f2db1ee | 297 | lcd.drawRect(50,3,30,8,FILL_TRANSPARENT); |
lukeocarwright | 31:cfdb014ff086 | 298 | printwav(lcd,submenu); //Prints Waveform |
lukeocarwright | 31:cfdb014ff086 | 299 | printfilter(lcd, filter_type); //Prints Filter Type |
lukeocarwright | 7:33cb5f2db1ee | 300 | lcd.refresh(); |
lukeocarwright | 15:1c67f064278e | 301 | } |
lukeocarwright | 13:27300c533dd1 | 302 | |
lukeocarwright | 24:c3bb1b0b2207 | 303 | void Front::initialise(Gamepad &pad, N5110 &lcd, int submenu) |
lukeocarwright | 24:c3bb1b0b2207 | 304 | { |
lukeocarwright | 24:c3bb1b0b2207 | 305 | out=sound.sound_main(true,submenu,440); //initialises external variables |
lukeocarwright | 27:da783f414f67 | 306 | out = filter.filter_run(out,1,true); //initialises LPF Filter |
lukeocarwright | 31:cfdb014ff086 | 307 | out = filter.filter_run(out,2,true); //initialises HPF Filter |
lukeocarwright | 31:cfdb014ff086 | 308 | out = filter.filter_run(out,3,true); //initialises BPF Filter |
lukeocarwright | 24:c3bb1b0b2207 | 309 | out=envelope.env_in(17,17,17,17,out,true); |
lukeocarwright | 24:c3bb1b0b2207 | 310 | out=envelope.release(17,17,out,true); |
lukeocarwright | 24:c3bb1b0b2207 | 311 | printsliders(lcd,17,17,17,17,1); //prints initialsliders |
lukeocarwright | 24:c3bb1b0b2207 | 312 | pad.reset_buttons(); |
lukeocarwright | 24:c3bb1b0b2207 | 313 | } |
lukeocarwright | 24:c3bb1b0b2207 | 314 | |
lukeocarwright | 13:27300c533dd1 | 315 | void Front::printsliders(N5110 &lcd, int a, int d, int s, int r, int used) |
lukeocarwright | 7:33cb5f2db1ee | 316 | { |
lukeocarwright | 31:cfdb014ff086 | 317 | //printf("USED(SLIDERS)=%d\n",used); |
lukeocarwright | 31:cfdb014ff086 | 318 | if(used==0) { //NONE |
lukeocarwright | 13:27300c533dd1 | 319 | printslider(lcd,3,a,false); |
lukeocarwright | 13:27300c533dd1 | 320 | printslider(lcd,15,d,false); |
lukeocarwright | 13:27300c533dd1 | 321 | printslider(lcd,27,s,false); |
lukeocarwright | 13:27300c533dd1 | 322 | printslider(lcd,39,r,false); |
lukeocarwright | 13:27300c533dd1 | 323 | } |
lukeocarwright | 31:cfdb014ff086 | 324 | if(used==1) { //ATTACK |
lukeocarwright | 13:27300c533dd1 | 325 | printslider(lcd,3,a,true); |
lukeocarwright | 13:27300c533dd1 | 326 | printslider(lcd,15,d,false); |
lukeocarwright | 13:27300c533dd1 | 327 | printslider(lcd,27,s,false); |
lukeocarwright | 13:27300c533dd1 | 328 | printslider(lcd,39,r,false); |
lukeocarwright | 13:27300c533dd1 | 329 | } |
lukeocarwright | 31:cfdb014ff086 | 330 | if(used==2) { //DECAY |
lukeocarwright | 13:27300c533dd1 | 331 | printslider(lcd,3,a,false); |
lukeocarwright | 13:27300c533dd1 | 332 | printslider(lcd,15,d,true); |
lukeocarwright | 13:27300c533dd1 | 333 | printslider(lcd,27,s,false); |
lukeocarwright | 13:27300c533dd1 | 334 | printslider(lcd,39,r,false); |
lukeocarwright | 13:27300c533dd1 | 335 | } |
lukeocarwright | 31:cfdb014ff086 | 336 | if(used==3) { //SUSTAIN |
lukeocarwright | 13:27300c533dd1 | 337 | printslider(lcd,3,a,false); |
lukeocarwright | 13:27300c533dd1 | 338 | printslider(lcd,15,d,false); |
lukeocarwright | 13:27300c533dd1 | 339 | printslider(lcd,27,s,true); |
lukeocarwright | 13:27300c533dd1 | 340 | printslider(lcd,39,r,false); |
lukeocarwright | 13:27300c533dd1 | 341 | } |
lukeocarwright | 31:cfdb014ff086 | 342 | if(used==4) { //Relase |
lukeocarwright | 13:27300c533dd1 | 343 | printslider(lcd,3,a,false); |
lukeocarwright | 13:27300c533dd1 | 344 | printslider(lcd,15,d,false); |
lukeocarwright | 13:27300c533dd1 | 345 | printslider(lcd,27,s,false); |
lukeocarwright | 13:27300c533dd1 | 346 | printslider(lcd,39,r,true); |
lukeocarwright | 13:27300c533dd1 | 347 | } |
lukeocarwright | 25:f230af268e8b | 348 | if(used>=5) { |
lukeocarwright | 25:f230af268e8b | 349 | printslider(lcd,3,a,false); |
lukeocarwright | 25:f230af268e8b | 350 | printslider(lcd,15,d,false); |
lukeocarwright | 25:f230af268e8b | 351 | printslider(lcd,27,s,false); |
lukeocarwright | 25:f230af268e8b | 352 | printslider(lcd,39,r,false); |
lukeocarwright | 26:a6033830d01c | 353 | } |
lukeocarwright | 13:27300c533dd1 | 354 | lcd.refresh(); |
lukeocarwright | 7:33cb5f2db1ee | 355 | } |
lukeocarwright | 13:27300c533dd1 | 356 | |
lukeocarwright | 13:27300c533dd1 | 357 | void Front::printslider(N5110 &lcd, int x_val, int y_val, bool use) |
lukeocarwright | 13:27300c533dd1 | 358 | { |
lukeocarwright | 13:27300c533dd1 | 359 | if (use==true) { |
lukeocarwright | 13:27300c533dd1 | 360 | lcd.drawRect(x_val,37-y_val,5,2,FILL_BLACK); |
lukeocarwright | 13:27300c533dd1 | 361 | } |
lukeocarwright | 13:27300c533dd1 | 362 | if (use==false) { |
lukeocarwright | 13:27300c533dd1 | 363 | lcd.drawRect(x_val,37-y_val,5,1,FILL_BLACK); |
lukeocarwright | 13:27300c533dd1 | 364 | } |
lukeocarwright | 13:27300c533dd1 | 365 | } |
lukeocarwright | 13:27300c533dd1 | 366 | |
lukeocarwright | 13:27300c533dd1 | 367 | |
lukeocarwright | 7:33cb5f2db1ee | 368 | void Front::printfader(N5110 &lcd, int x, int y) |
lukeocarwright | 7:33cb5f2db1ee | 369 | { |
lukeocarwright | 7:33cb5f2db1ee | 370 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 7:33cb5f2db1ee | 371 | lcd.drawSprite(x,y,35,5,(int *)fader); |
lukeocarwright | 7:33cb5f2db1ee | 372 | } |
lukeocarwright | 7:33cb5f2db1ee | 373 | |
lukeocarwright | 7:33cb5f2db1ee | 374 | void Front::printwav(N5110 &lcd, int submenu) |
lukeocarwright | 7:33cb5f2db1ee | 375 | { |
lukeocarwright | 7:33cb5f2db1ee | 376 | if (submenu==1) { |
lukeocarwright | 7:33cb5f2db1ee | 377 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 31:cfdb014ff086 | 378 | lcd.drawSprite(51,4,6,28,(int *)sin_wav); //sin |
lukeocarwright | 7:33cb5f2db1ee | 379 | } |
lukeocarwright | 7:33cb5f2db1ee | 380 | if (submenu==2) { |
lukeocarwright | 7:33cb5f2db1ee | 381 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 31:cfdb014ff086 | 382 | lcd.drawSprite(51,4,6,28,(int *)tri_wav); //tri |
lukeocarwright | 7:33cb5f2db1ee | 383 | } |
lukeocarwright | 7:33cb5f2db1ee | 384 | if (submenu==3) { |
lukeocarwright | 7:33cb5f2db1ee | 385 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 31:cfdb014ff086 | 386 | lcd.drawSprite(51,4,6,28,(int *)square_wav); //sqr |
lukeocarwright | 7:33cb5f2db1ee | 387 | } |
lukeocarwright | 13:27300c533dd1 | 388 | } |
lukeocarwright | 13:27300c533dd1 | 389 | |
lukeocarwright | 25:f230af268e8b | 390 | void Front::printfilter(N5110 &lcd, int filter_type) |
lukeocarwright | 25:f230af268e8b | 391 | { |
lukeocarwright | 25:f230af268e8b | 392 | if (filter_type>=1) { |
lukeocarwright | 25:f230af268e8b | 393 | lcd.drawLine(51,32,51,12,1); //y axis |
lukeocarwright | 25:f230af268e8b | 394 | lcd.drawLine(51,32,81,32,1); //x axis |
lukeocarwright | 25:f230af268e8b | 395 | if (filter_type==1) { |
lukeocarwright | 31:cfdb014ff086 | 396 | lcd.drawSprite(52,13,19,29,(int *)Low_pass); //LPF |
lukeocarwright | 25:f230af268e8b | 397 | lcd.printString("L",45,2); |
lukeocarwright | 25:f230af268e8b | 398 | } |
lukeocarwright | 25:f230af268e8b | 399 | if (filter_type==2) { |
lukeocarwright | 31:cfdb014ff086 | 400 | lcd.drawSprite(52,13,19,29,(int *)High_pass); //HPF |
lukeocarwright | 25:f230af268e8b | 401 | lcd.printString("H",45,2); |
lukeocarwright | 25:f230af268e8b | 402 | } |
lukeocarwright | 25:f230af268e8b | 403 | if (filter_type==3) { |
lukeocarwright | 31:cfdb014ff086 | 404 | lcd.drawSprite(52,13,19,29,(int *)Band_pass); //BPF |
lukeocarwright | 25:f230af268e8b | 405 | lcd.printString("B",45,2); |
lukeocarwright | 25:f230af268e8b | 406 | } |
lukeocarwright | 25:f230af268e8b | 407 | } |
lukeocarwright | 25:f230af268e8b | 408 | } |
lukeocarwright | 25:f230af268e8b | 409 | |
lukeocarwright | 13:27300c533dd1 | 410 | int Front::incrament_adsr(int used, int adsr, int ud) |
lukeocarwright | 13:27300c533dd1 | 411 | { |
lukeocarwright | 31:cfdb014ff086 | 412 | if (used<=4) { //Num of Faders |
lukeocarwright | 31:cfdb014ff086 | 413 | if (ud==1) { //Up |
lukeocarwright | 25:f230af268e8b | 414 | adsr++; |
lukeocarwright | 25:f230af268e8b | 415 | if (adsr>35) { |
lukeocarwright | 25:f230af268e8b | 416 | adsr--; |
lukeocarwright | 25:f230af268e8b | 417 | } |
lukeocarwright | 13:27300c533dd1 | 418 | } |
lukeocarwright | 31:cfdb014ff086 | 419 | if (ud==-1) {//Down |
lukeocarwright | 25:f230af268e8b | 420 | adsr--; |
lukeocarwright | 25:f230af268e8b | 421 | if (adsr<1) { |
lukeocarwright | 25:f230af268e8b | 422 | adsr++; |
lukeocarwright | 25:f230af268e8b | 423 | } |
lukeocarwright | 13:27300c533dd1 | 424 | } |
lukeocarwright | 13:27300c533dd1 | 425 | } |
lukeocarwright | 26:a6033830d01c | 426 | if (used==5) { |
lukeocarwright | 31:cfdb014ff086 | 427 | adsr=incrament_filter(adsr,ud); //Filter Type Change |
lukeocarwright | 26:a6033830d01c | 428 | } |
lukeocarwright | 26:a6033830d01c | 429 | return(adsr); |
lukeocarwright | 26:a6033830d01c | 430 | } |
lukeocarwright | 26:a6033830d01c | 431 | |
lukeocarwright | 26:a6033830d01c | 432 | int Front::incrament_filter(int adsr, int ud) |
lukeocarwright | 26:a6033830d01c | 433 | { |
lukeocarwright | 31:cfdb014ff086 | 434 | if (ud==1) { //UP |
lukeocarwright | 26:a6033830d01c | 435 | adsr++; |
lukeocarwright | 31:cfdb014ff086 | 436 | if (adsr>3) { //Max Filters |
lukeocarwright | 26:a6033830d01c | 437 | adsr--; |
lukeocarwright | 26:a6033830d01c | 438 | } |
lukeocarwright | 26:a6033830d01c | 439 | } |
lukeocarwright | 31:cfdb014ff086 | 440 | if (ud==-1) { //down |
lukeocarwright | 26:a6033830d01c | 441 | adsr--; |
lukeocarwright | 26:a6033830d01c | 442 | if (adsr<0) { |
lukeocarwright | 26:a6033830d01c | 443 | adsr++; |
lukeocarwright | 26:a6033830d01c | 444 | } |
lukeocarwright | 26:a6033830d01c | 445 | } |
lukeocarwright | 13:27300c533dd1 | 446 | return(adsr); |
lukeocarwright | 19:08862f49cd9e | 447 | } |
lukeocarwright | 19:08862f49cd9e | 448 | |
lukeocarwright | 28:eb0f12304a45 | 449 | int Front::frequency_convert(Gamepad &pad,int oct) |
lukeocarwright | 31:cfdb014ff086 | 450 | { |
lukeocarwright | 31:cfdb014ff086 | 451 | frequency=55*(pow(2.0,oct)); //Converts to correct Octave Start |
lukeocarwright | 31:cfdb014ff086 | 452 | frequency=(frequency+(pad.read_pot1()*frequency)); //Generates Exact Frequency |
lukeocarwright | 24:c3bb1b0b2207 | 453 | return(frequency); |
lukeocarwright | 24:c3bb1b0b2207 | 454 | } |
lukeocarwright | 24:c3bb1b0b2207 | 455 | |
lukeocarwright | 31:cfdb014ff086 | 456 | int Front::fader_select(int used,int lr) |
lukeocarwright | 31:cfdb014ff086 | 457 | { |
lukeocarwright | 31:cfdb014ff086 | 458 | if (lr==1) { //Right |
lukeocarwright | 31:cfdb014ff086 | 459 | used++; |
lukeocarwright | 31:cfdb014ff086 | 460 | if (used>5) { //Max |
lukeocarwright | 31:cfdb014ff086 | 461 | used=5; |
lukeocarwright | 31:cfdb014ff086 | 462 | } |
lukeocarwright | 31:cfdb014ff086 | 463 | } |
lukeocarwright | 31:cfdb014ff086 | 464 | if(lr==-1) { ///Left |
lukeocarwright | 31:cfdb014ff086 | 465 | used--; |
lukeocarwright | 31:cfdb014ff086 | 466 | if(used<1) { //Min |
lukeocarwright | 31:cfdb014ff086 | 467 | used=1; |
lukeocarwright | 31:cfdb014ff086 | 468 | } |
lukeocarwright | 31:cfdb014ff086 | 469 | } |
lukeocarwright | 31:cfdb014ff086 | 470 | //printf("INCRAMENT USED= %d\n",used); //debug |
lukeocarwright | 31:cfdb014ff086 | 471 | return(used); |
lukeocarwright | 31:cfdb014ff086 | 472 | } |
lukeocarwright | 31:cfdb014ff086 | 473 | |
lukeocarwright | 19:08862f49cd9e | 474 | #ifdef SLOW_TIME |
lukeocarwright | 19:08862f49cd9e | 475 | void Front::print_SLOWTIME_out (uint16_t out, bool noteon, int a, int d, int s, int r, int release_flag, int silent_flag) |
lukeocarwright | 19:08862f49cd9e | 476 | { |
lukeocarwright | 19:08862f49cd9e | 477 | //Prints all data required in SLOW_TIME |
lukeocarwright | 19:08862f49cd9e | 478 | printf("OUTPUT:%d\n",out); |
lukeocarwright | 19:08862f49cd9e | 479 | printf("NOTEON: %d\n",noteon); |
lukeocarwright | 19:08862f49cd9e | 480 | printf("A:%d,D:%d,S:%d,R:%d\n",a,d,s,r); |
lukeocarwright | 19:08862f49cd9e | 481 | printf("RelFlag=%d, SilFlag=%d\n\n",release_flag,silent_flag); |
lukeocarwright | 19:08862f49cd9e | 482 | } |
lukeocarwright | 19:08862f49cd9e | 483 | #endif |