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.
Dependencies: mbed
Front/Front.cpp@30:08cc4ec58d07, 2020-05-26 (annotated)
- Committer:
- lukeocarwright
- Date:
- Tue May 26 10:17:47 2020 +0000
- Revision:
- 30:08cc4ec58d07
- Parent:
- 29:207111ffd6e6
- Child:
- 31:cfdb014ff086
Sorted Settings Menu Final Touches. More Code Tidying.
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 | 19:08862f49cd9e | 172 | pad.write_u16(out); |
| 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 | 19:08862f49cd9e | 175 | if (release_flag==0) { |
| lukeocarwright | 27:da783f414f67 | 176 | out=(envelope.env_in(a,d,s,r,envelope_in,false));//Uint around 32767 |
| lukeocarwright | 19:08862f49cd9e | 177 | } else { |
| lukeocarwright | 19:08862f49cd9e | 178 | out=envelope.release(s,r,envelope_in,false); |
| lukeocarwright | 19:08862f49cd9e | 179 | if (silent_flag==1) { |
| lukeocarwright | 19:08862f49cd9e | 180 | release_flag=0; |
| lukeocarwright | 19:08862f49cd9e | 181 | silent_flag=0; |
| lukeocarwright | 19:08862f49cd9e | 182 | noteon=false; |
| lukeocarwright | 19:08862f49cd9e | 183 | out=envelope.env_in(a,d,s,r,out,true); |
| lukeocarwright | 19:08862f49cd9e | 184 | out=0; |
| lukeocarwright | 19:08862f49cd9e | 185 | } |
| lukeocarwright | 19:08862f49cd9e | 186 | } |
| lukeocarwright | 19:08862f49cd9e | 187 | g_isr_flag=0; |
| lukeocarwright | 18:204cd747b54a | 188 | #ifdef CSV |
| 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 | 13:27300c533dd1 | 193 | dir=pad.get_direction(); |
| lukeocarwright | 13:27300c533dd1 | 194 | if (dir!=dir_1) { |
| lukeocarwright | 30:08cc4ec58d07 | 195 | //printf("dir =%d\n",dir); //debug |
| lukeocarwright | 13:27300c533dd1 | 196 | if(dir==3) { |
| lukeocarwright | 13:27300c533dd1 | 197 | used++; |
| lukeocarwright | 25:f230af268e8b | 198 | if (used>5) { |
| lukeocarwright | 25:f230af268e8b | 199 | used=5; |
| lukeocarwright | 13:27300c533dd1 | 200 | } |
| lukeocarwright | 13:27300c533dd1 | 201 | } |
| lukeocarwright | 13:27300c533dd1 | 202 | if (dir==7) { |
| lukeocarwright | 13:27300c533dd1 | 203 | used--; |
| lukeocarwright | 13:27300c533dd1 | 204 | if(used<1) { |
| lukeocarwright | 13:27300c533dd1 | 205 | used=1; |
| lukeocarwright | 13:27300c533dd1 | 206 | } |
| lukeocarwright | 13:27300c533dd1 | 207 | } |
| lukeocarwright | 13:27300c533dd1 | 208 | if (dir==1) { |
| lukeocarwright | 13:27300c533dd1 | 209 | if (used==1) { |
| lukeocarwright | 13:27300c533dd1 | 210 | a=incrament_adsr(used,a,1); |
| lukeocarwright | 13:27300c533dd1 | 211 | } |
| lukeocarwright | 13:27300c533dd1 | 212 | if (used==2) { |
| lukeocarwright | 13:27300c533dd1 | 213 | d=incrament_adsr(used,d,1); |
| lukeocarwright | 13:27300c533dd1 | 214 | } |
| lukeocarwright | 13:27300c533dd1 | 215 | if (used==3) { |
| lukeocarwright | 13:27300c533dd1 | 216 | s=incrament_adsr(used,s,1); |
| lukeocarwright | 13:27300c533dd1 | 217 | } |
| lukeocarwright | 13:27300c533dd1 | 218 | if (used==4) { |
| lukeocarwright | 13:27300c533dd1 | 219 | r=incrament_adsr(used,r,1); |
| lukeocarwright | 13:27300c533dd1 | 220 | } |
| lukeocarwright | 26:a6033830d01c | 221 | if (used==5) { |
| lukeocarwright | 26:a6033830d01c | 222 | filter_type=incrament_adsr(used,filter_type,-1); |
| lukeocarwright | 26:a6033830d01c | 223 | printf("FILTER_TYPE=%d\n",filter_type); |
| lukeocarwright | 26:a6033830d01c | 224 | } |
| lukeocarwright | 13:27300c533dd1 | 225 | } |
| lukeocarwright | 13:27300c533dd1 | 226 | |
| lukeocarwright | 13:27300c533dd1 | 227 | if (dir==5) { |
| lukeocarwright | 13:27300c533dd1 | 228 | if (used==1) { |
| lukeocarwright | 13:27300c533dd1 | 229 | a=incrament_adsr(used,a,-1); |
| lukeocarwright | 13:27300c533dd1 | 230 | } |
| lukeocarwright | 13:27300c533dd1 | 231 | if (used==2) { |
| lukeocarwright | 13:27300c533dd1 | 232 | d=incrament_adsr(used,d,-1); |
| lukeocarwright | 13:27300c533dd1 | 233 | } |
| lukeocarwright | 13:27300c533dd1 | 234 | if (used==3) { |
| lukeocarwright | 13:27300c533dd1 | 235 | s=incrament_adsr(used,s,-1); |
| lukeocarwright | 13:27300c533dd1 | 236 | } |
| lukeocarwright | 13:27300c533dd1 | 237 | if (used==4) { |
| lukeocarwright | 13:27300c533dd1 | 238 | r=incrament_adsr(used,r,-1); |
| lukeocarwright | 13:27300c533dd1 | 239 | } |
| lukeocarwright | 26:a6033830d01c | 240 | if (used==5) { |
| lukeocarwright | 26:a6033830d01c | 241 | filter_type=incrament_adsr(used,filter_type,1); |
| lukeocarwright | 26:a6033830d01c | 242 | printf("FILTER_TYPE=%d\n",filter_type); |
| lukeocarwright | 26:a6033830d01c | 243 | } |
| lukeocarwright | 13:27300c533dd1 | 244 | } |
| lukeocarwright | 25:f230af268e8b | 245 | frontsetup(lcd,pad,submenu,filter_type,false); |
| lukeocarwright | 13:27300c533dd1 | 246 | printsliders(lcd,a,d,s,r,used); |
| lukeocarwright | 26:a6033830d01c | 247 | wait_ms(80); |
| lukeocarwright | 18:204cd747b54a | 248 | } //END if DIR |
| lukeocarwright | 18:204cd747b54a | 249 | if ( pad.A_pressed()) { //NOTE ON |
| lukeocarwright | 18:204cd747b54a | 250 | printf("NOTE_ON\n"); |
| lukeocarwright | 18:204cd747b54a | 251 | noteon=true; |
| lukeocarwright | 18:204cd747b54a | 252 | out=envelope.env_in(a,d,s,r,out,true); |
| lukeocarwright | 28:eb0f12304a45 | 253 | frequency=frequency_convert(pad,oct); |
| lukeocarwright | 18:204cd747b54a | 254 | } |
| lukeocarwright | 18:204cd747b54a | 255 | if ( pad.B_pressed()) { //NOTE OFF |
| lukeocarwright | 19:08862f49cd9e | 256 | //printf("NOTE_OFF (W.release)\n"); |
| lukeocarwright | 19:08862f49cd9e | 257 | release_flag=1; |
| lukeocarwright | 19:08862f49cd9e | 258 | envelope_in=envelope.release(s,r,envelope_in,true); |
| lukeocarwright | 19:08862f49cd9e | 259 | pad.reset_buttons(); |
| lukeocarwright | 18:204cd747b54a | 260 | } |
| lukeocarwright | 28:eb0f12304a45 | 261 | if ( pad.X_pressed()) { |
| lukeocarwright | 28:eb0f12304a45 | 262 | oct--; |
| lukeocarwright | 28:eb0f12304a45 | 263 | if (oct<0) {oct++;} |
| lukeocarwright | 28:eb0f12304a45 | 264 | printf("OCTAVE %d\n",oct); |
| lukeocarwright | 27:da783f414f67 | 265 | pad.reset_buttons(); |
| lukeocarwright | 27:da783f414f67 | 266 | } |
| lukeocarwright | 27:da783f414f67 | 267 | if ( pad.Y_pressed()) { |
| lukeocarwright | 28:eb0f12304a45 | 268 | oct++; |
| lukeocarwright | 28:eb0f12304a45 | 269 | if (oct>5) {oct--;} |
| lukeocarwright | 28:eb0f12304a45 | 270 | printf("OCTAVE %d\n",oct); |
| lukeocarwright | 27:da783f414f67 | 271 | pad.reset_buttons(); |
| lukeocarwright | 27:da783f414f67 | 272 | } |
| lukeocarwright | 18:204cd747b54a | 273 | |
| lukeocarwright | 18:204cd747b54a | 274 | if (pad.start_pressed()) { //go back menu |
| lukeocarwright | 18:204cd747b54a | 275 | // printf("start pressed\n"); |
| lukeocarwright | 18:204cd747b54a | 276 | printf("Waveforms Sub selected\n"); //debug |
| lukeocarwright | 18:204cd747b54a | 277 | noteon=false; |
| lukeocarwright | 18:204cd747b54a | 278 | menuflag=0; //sets flag |
| lukeocarwright | 29:207111ffd6e6 | 279 | break; |
| lukeocarwright | 8:f305ea78b2b1 | 280 | } |
| lukeocarwright | 13:27300c533dd1 | 281 | dir=dir_1; |
| lukeocarwright | 19:08862f49cd9e | 282 | sleep(); //puts sleep until ISR wakes up |
| lukeocarwright | 19:08862f49cd9e | 283 | } |
| lukeocarwright | 8:f305ea78b2b1 | 284 | } |
| lukeocarwright | 8:f305ea78b2b1 | 285 | |
| lukeocarwright | 8:f305ea78b2b1 | 286 | //PRIVATE----------------------------------------------------------------------- |
| lukeocarwright | 8:f305ea78b2b1 | 287 | |
| lukeocarwright | 25:f230af268e8b | 288 | void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, int filter_type, bool initial) |
| lukeocarwright | 7:33cb5f2db1ee | 289 | { |
| lukeocarwright | 13:27300c533dd1 | 290 | if (initial==true) { |
| lukeocarwright | 13:27300c533dd1 | 291 | printsliders(lcd,17,17,17,17,1); |
| lukeocarwright | 30:08cc4ec58d07 | 292 | initialise(pad,lcd,submenu); |
| lukeocarwright | 25:f230af268e8b | 293 | |
| lukeocarwright | 13:27300c533dd1 | 294 | } |
| lukeocarwright | 7:33cb5f2db1ee | 295 | lcd.clear(); |
| lukeocarwright | 7:33cb5f2db1ee | 296 | lcd.printString("A D S R",3,5); |
| lukeocarwright | 7:33cb5f2db1ee | 297 | printfader(lcd,3,3); |
| lukeocarwright | 7:33cb5f2db1ee | 298 | printfader(lcd,15,3); |
| lukeocarwright | 7:33cb5f2db1ee | 299 | printfader(lcd,27,3); |
| lukeocarwright | 7:33cb5f2db1ee | 300 | printfader(lcd,39,3); |
| lukeocarwright | 7:33cb5f2db1ee | 301 | lcd.drawRect(50,3,30,8,FILL_TRANSPARENT); |
| lukeocarwright | 7:33cb5f2db1ee | 302 | printwav(lcd,submenu); |
| lukeocarwright | 26:a6033830d01c | 303 | printfilter(lcd, filter_type); |
| lukeocarwright | 7:33cb5f2db1ee | 304 | lcd.refresh(); |
| lukeocarwright | 15:1c67f064278e | 305 | } |
| lukeocarwright | 13:27300c533dd1 | 306 | |
| lukeocarwright | 24:c3bb1b0b2207 | 307 | void Front::initialise(Gamepad &pad, N5110 &lcd, int submenu) |
| lukeocarwright | 24:c3bb1b0b2207 | 308 | { |
| lukeocarwright | 24:c3bb1b0b2207 | 309 | out=sound.sound_main(true,submenu,440); //initialises external variables |
| lukeocarwright | 27:da783f414f67 | 310 | out = filter.filter_run(out,1,true); //initialises LPF Filter |
| lukeocarwright | 27:da783f414f67 | 311 | out = filter.filter_run(out,2,true); //initialises LPF Filter |
| lukeocarwright | 27:da783f414f67 | 312 | out = filter.filter_run(out,3,true); //initialises LPF Filter |
| lukeocarwright | 24:c3bb1b0b2207 | 313 | out=envelope.env_in(17,17,17,17,out,true); |
| lukeocarwright | 24:c3bb1b0b2207 | 314 | out=envelope.release(17,17,out,true); |
| lukeocarwright | 24:c3bb1b0b2207 | 315 | printsliders(lcd,17,17,17,17,1); //prints initialsliders |
| lukeocarwright | 24:c3bb1b0b2207 | 316 | pad.reset_buttons(); |
| lukeocarwright | 24:c3bb1b0b2207 | 317 | } |
| lukeocarwright | 24:c3bb1b0b2207 | 318 | |
| lukeocarwright | 13:27300c533dd1 | 319 | void Front::printsliders(N5110 &lcd, int a, int d, int s, int r, int used) |
| lukeocarwright | 7:33cb5f2db1ee | 320 | { |
| lukeocarwright | 13:27300c533dd1 | 321 | if(used==0) { |
| lukeocarwright | 13:27300c533dd1 | 322 | printslider(lcd,3,a,false); |
| lukeocarwright | 13:27300c533dd1 | 323 | printslider(lcd,15,d,false); |
| lukeocarwright | 13:27300c533dd1 | 324 | printslider(lcd,27,s,false); |
| lukeocarwright | 13:27300c533dd1 | 325 | printslider(lcd,39,r,false); |
| lukeocarwright | 13:27300c533dd1 | 326 | } |
| lukeocarwright | 13:27300c533dd1 | 327 | if(used==1) { |
| lukeocarwright | 13:27300c533dd1 | 328 | printslider(lcd,3,a,true); |
| lukeocarwright | 13:27300c533dd1 | 329 | printslider(lcd,15,d,false); |
| lukeocarwright | 13:27300c533dd1 | 330 | printslider(lcd,27,s,false); |
| lukeocarwright | 13:27300c533dd1 | 331 | printslider(lcd,39,r,false); |
| lukeocarwright | 13:27300c533dd1 | 332 | } |
| lukeocarwright | 13:27300c533dd1 | 333 | if(used==2) { |
| lukeocarwright | 13:27300c533dd1 | 334 | printslider(lcd,3,a,false); |
| lukeocarwright | 13:27300c533dd1 | 335 | printslider(lcd,15,d,true); |
| lukeocarwright | 13:27300c533dd1 | 336 | printslider(lcd,27,s,false); |
| lukeocarwright | 13:27300c533dd1 | 337 | printslider(lcd,39,r,false); |
| lukeocarwright | 13:27300c533dd1 | 338 | } |
| lukeocarwright | 13:27300c533dd1 | 339 | if(used==3) { |
| lukeocarwright | 13:27300c533dd1 | 340 | printslider(lcd,3,a,false); |
| lukeocarwright | 13:27300c533dd1 | 341 | printslider(lcd,15,d,false); |
| lukeocarwright | 13:27300c533dd1 | 342 | printslider(lcd,27,s,true); |
| lukeocarwright | 13:27300c533dd1 | 343 | printslider(lcd,39,r,false); |
| lukeocarwright | 13:27300c533dd1 | 344 | } |
| lukeocarwright | 13:27300c533dd1 | 345 | if(used==4) { |
| lukeocarwright | 13:27300c533dd1 | 346 | printslider(lcd,3,a,false); |
| lukeocarwright | 13:27300c533dd1 | 347 | printslider(lcd,15,d,false); |
| lukeocarwright | 13:27300c533dd1 | 348 | printslider(lcd,27,s,false); |
| lukeocarwright | 13:27300c533dd1 | 349 | printslider(lcd,39,r,true); |
| lukeocarwright | 13:27300c533dd1 | 350 | } |
| lukeocarwright | 25:f230af268e8b | 351 | if(used>=5) { |
| lukeocarwright | 25:f230af268e8b | 352 | printslider(lcd,3,a,false); |
| lukeocarwright | 25:f230af268e8b | 353 | printslider(lcd,15,d,false); |
| lukeocarwright | 25:f230af268e8b | 354 | printslider(lcd,27,s,false); |
| lukeocarwright | 25:f230af268e8b | 355 | printslider(lcd,39,r,false); |
| lukeocarwright | 26:a6033830d01c | 356 | } |
| lukeocarwright | 13:27300c533dd1 | 357 | lcd.refresh(); |
| lukeocarwright | 7:33cb5f2db1ee | 358 | } |
| lukeocarwright | 13:27300c533dd1 | 359 | |
| lukeocarwright | 13:27300c533dd1 | 360 | void Front::printslider(N5110 &lcd, int x_val, int y_val, bool use) |
| lukeocarwright | 13:27300c533dd1 | 361 | { |
| lukeocarwright | 13:27300c533dd1 | 362 | if (use==true) { |
| lukeocarwright | 13:27300c533dd1 | 363 | lcd.drawRect(x_val,37-y_val,5,2,FILL_BLACK); |
| lukeocarwright | 13:27300c533dd1 | 364 | } |
| lukeocarwright | 13:27300c533dd1 | 365 | if (use==false) { |
| lukeocarwright | 13:27300c533dd1 | 366 | lcd.drawRect(x_val,37-y_val,5,1,FILL_BLACK); |
| lukeocarwright | 13:27300c533dd1 | 367 | } |
| lukeocarwright | 13:27300c533dd1 | 368 | } |
| lukeocarwright | 13:27300c533dd1 | 369 | |
| lukeocarwright | 13:27300c533dd1 | 370 | |
| lukeocarwright | 7:33cb5f2db1ee | 371 | void Front::printfader(N5110 &lcd, int x, int y) |
| lukeocarwright | 7:33cb5f2db1ee | 372 | { |
| lukeocarwright | 7:33cb5f2db1ee | 373 | // x origin, y origin, rows, cols, sprite |
| lukeocarwright | 7:33cb5f2db1ee | 374 | lcd.drawSprite(x,y,35,5,(int *)fader); |
| lukeocarwright | 7:33cb5f2db1ee | 375 | } |
| lukeocarwright | 7:33cb5f2db1ee | 376 | |
| lukeocarwright | 7:33cb5f2db1ee | 377 | void Front::printwav(N5110 &lcd, int submenu) |
| lukeocarwright | 7:33cb5f2db1ee | 378 | { |
| lukeocarwright | 7:33cb5f2db1ee | 379 | if (submenu==1) { |
| lukeocarwright | 7:33cb5f2db1ee | 380 | // x origin, y origin, rows, cols, sprite |
| lukeocarwright | 7:33cb5f2db1ee | 381 | lcd.drawSprite(51,4,6,28,(int *)sin_wav); |
| lukeocarwright | 7:33cb5f2db1ee | 382 | } |
| lukeocarwright | 7:33cb5f2db1ee | 383 | if (submenu==2) { |
| lukeocarwright | 7:33cb5f2db1ee | 384 | // x origin, y origin, rows, cols, sprite |
| lukeocarwright | 7:33cb5f2db1ee | 385 | lcd.drawSprite(51,4,6,28,(int *)tri_wav); |
| lukeocarwright | 7:33cb5f2db1ee | 386 | } |
| lukeocarwright | 7:33cb5f2db1ee | 387 | if (submenu==3) { |
| lukeocarwright | 7:33cb5f2db1ee | 388 | // x origin, y origin, rows, cols, sprite |
| lukeocarwright | 7:33cb5f2db1ee | 389 | lcd.drawSprite(51,4,6,28,(int *)square_wav); |
| lukeocarwright | 7:33cb5f2db1ee | 390 | } |
| lukeocarwright | 13:27300c533dd1 | 391 | } |
| lukeocarwright | 13:27300c533dd1 | 392 | |
| lukeocarwright | 25:f230af268e8b | 393 | void Front::printfilter(N5110 &lcd, int filter_type) |
| lukeocarwright | 25:f230af268e8b | 394 | { |
| lukeocarwright | 25:f230af268e8b | 395 | if (filter_type>=1) { |
| lukeocarwright | 25:f230af268e8b | 396 | lcd.drawLine(51,32,51,12,1); //y axis |
| lukeocarwright | 25:f230af268e8b | 397 | lcd.drawLine(51,32,81,32,1); //x axis |
| lukeocarwright | 25:f230af268e8b | 398 | if (filter_type==1) { |
| lukeocarwright | 25:f230af268e8b | 399 | lcd.drawSprite(52,13,19,29,(int *)Low_pass); |
| lukeocarwright | 25:f230af268e8b | 400 | lcd.printString("L",45,2); |
| lukeocarwright | 25:f230af268e8b | 401 | } |
| lukeocarwright | 25:f230af268e8b | 402 | if (filter_type==2) { |
| lukeocarwright | 25:f230af268e8b | 403 | lcd.drawSprite(52,13,19,29,(int *)High_pass); |
| lukeocarwright | 25:f230af268e8b | 404 | lcd.printString("H",45,2); |
| lukeocarwright | 25:f230af268e8b | 405 | } |
| lukeocarwright | 25:f230af268e8b | 406 | if (filter_type==3) { |
| lukeocarwright | 25:f230af268e8b | 407 | lcd.drawSprite(52,13,19,29,(int *)Band_pass); |
| lukeocarwright | 25:f230af268e8b | 408 | lcd.printString("B",45,2); |
| lukeocarwright | 25:f230af268e8b | 409 | } |
| lukeocarwright | 25:f230af268e8b | 410 | } |
| lukeocarwright | 25:f230af268e8b | 411 | } |
| lukeocarwright | 25:f230af268e8b | 412 | |
| lukeocarwright | 25:f230af268e8b | 413 | int Front::parameter_manager(Gamepad &pad, int dir, int a, int d, int s, int r) |
| lukeocarwright | 25:f230af268e8b | 414 | { |
| lukeocarwright | 25:f230af268e8b | 415 | |
| lukeocarwright | 25:f230af268e8b | 416 | return(used); |
| lukeocarwright | 25:f230af268e8b | 417 | } |
| lukeocarwright | 25:f230af268e8b | 418 | |
| lukeocarwright | 13:27300c533dd1 | 419 | int Front::incrament_adsr(int used, int adsr, int ud) |
| lukeocarwright | 13:27300c533dd1 | 420 | { |
| lukeocarwright | 25:f230af268e8b | 421 | if (used<=4) { |
| lukeocarwright | 25:f230af268e8b | 422 | if (ud==1) { |
| lukeocarwright | 25:f230af268e8b | 423 | adsr++; |
| lukeocarwright | 25:f230af268e8b | 424 | if (adsr>35) { |
| lukeocarwright | 25:f230af268e8b | 425 | adsr--; |
| lukeocarwright | 25:f230af268e8b | 426 | } |
| lukeocarwright | 13:27300c533dd1 | 427 | } |
| lukeocarwright | 25:f230af268e8b | 428 | if (ud==-1) { |
| lukeocarwright | 25:f230af268e8b | 429 | adsr--; |
| lukeocarwright | 25:f230af268e8b | 430 | if (adsr<1) { |
| lukeocarwright | 25:f230af268e8b | 431 | adsr++; |
| lukeocarwright | 25:f230af268e8b | 432 | } |
| lukeocarwright | 13:27300c533dd1 | 433 | } |
| lukeocarwright | 13:27300c533dd1 | 434 | } |
| lukeocarwright | 26:a6033830d01c | 435 | if (used==5) { |
| lukeocarwright | 26:a6033830d01c | 436 | adsr=incrament_filter(adsr,ud); |
| lukeocarwright | 26:a6033830d01c | 437 | } |
| lukeocarwright | 26:a6033830d01c | 438 | return(adsr); |
| lukeocarwright | 26:a6033830d01c | 439 | } |
| lukeocarwright | 26:a6033830d01c | 440 | |
| lukeocarwright | 26:a6033830d01c | 441 | int Front::incrament_filter(int adsr, int ud) |
| lukeocarwright | 26:a6033830d01c | 442 | { |
| lukeocarwright | 26:a6033830d01c | 443 | if (ud==1) { |
| lukeocarwright | 26:a6033830d01c | 444 | adsr++; |
| lukeocarwright | 26:a6033830d01c | 445 | if (adsr>3) { |
| lukeocarwright | 26:a6033830d01c | 446 | adsr--; |
| lukeocarwright | 26:a6033830d01c | 447 | } |
| lukeocarwright | 26:a6033830d01c | 448 | } |
| lukeocarwright | 26:a6033830d01c | 449 | if (ud==-1) { |
| lukeocarwright | 26:a6033830d01c | 450 | adsr--; |
| lukeocarwright | 26:a6033830d01c | 451 | if (adsr<0) { |
| lukeocarwright | 26:a6033830d01c | 452 | adsr++; |
| lukeocarwright | 26:a6033830d01c | 453 | } |
| lukeocarwright | 26:a6033830d01c | 454 | } |
| lukeocarwright | 13:27300c533dd1 | 455 | return(adsr); |
| lukeocarwright | 19:08862f49cd9e | 456 | } |
| lukeocarwright | 19:08862f49cd9e | 457 | |
| lukeocarwright | 28:eb0f12304a45 | 458 | int Front::frequency_convert(Gamepad &pad,int oct) |
| lukeocarwright | 28:eb0f12304a45 | 459 | { |
| lukeocarwright | 28:eb0f12304a45 | 460 | frequency=55*(pow(2.0,oct)); |
| lukeocarwright | 28:eb0f12304a45 | 461 | frequency=(frequency+(pad.read_pot1()*frequency)); |
| lukeocarwright | 24:c3bb1b0b2207 | 462 | return(frequency); |
| lukeocarwright | 24:c3bb1b0b2207 | 463 | } |
| lukeocarwright | 24:c3bb1b0b2207 | 464 | |
| lukeocarwright | 19:08862f49cd9e | 465 | #ifdef SLOW_TIME |
| lukeocarwright | 19:08862f49cd9e | 466 | 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 | 467 | { |
| lukeocarwright | 19:08862f49cd9e | 468 | //Prints all data required in SLOW_TIME |
| lukeocarwright | 19:08862f49cd9e | 469 | printf("OUTPUT:%d\n",out); |
| lukeocarwright | 19:08862f49cd9e | 470 | printf("NOTEON: %d\n",noteon); |
| lukeocarwright | 19:08862f49cd9e | 471 | printf("A:%d,D:%d,S:%d,R:%d\n",a,d,s,r); |
| lukeocarwright | 19:08862f49cd9e | 472 | printf("RelFlag=%d, SilFlag=%d\n\n",release_flag,silent_flag); |
| lukeocarwright | 19:08862f49cd9e | 473 | } |
| lukeocarwright | 19:08862f49cd9e | 474 | #endif |