├── Documentation.txt ├── Dokumentacja.txt ├── LICENSE.txt ├── examples ├── JSBach_Toccata-d │ └── JSBach_Toccata-d.ino └── tetris_A-theme │ └── tetris_A-theme.ino ├── keywords.txt ├── library.properties └── src ├── asmsynth.S ├── asmsynth.c ├── asmsynth.h ├── config.h └── iosupport.h /Documentation.txt: -------------------------------------------------------------------------------- 1 | This documentation is translated and may contain possible translation errors, originally written in Polish. 2 | 3 | INTRODUCTION 4 | 5 | 6 | 7 | The asmsynth library allows you to create 8-bit music. It simulates the work of a synthesizer and allows you to generate up to 32 voices. Square, sawtooth or triangular wave can be generated, most likely sine wave and noise will also be added. This library also introduces two-programmability, it can execute two programs asynchronously at the same time to allow background music to be played. H-bridge support is introduced, it can be used as an amplifier for loudspeakers or you can also control the operation of the motors (and instead of a squeaking PWM melody will play: D). 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Library configuration 16 | 17 | The library in its folder has a configuration file (config.h), there are all settings (used pins, counters, library work modes). You can edit this file with notepad. Library dedicated to ATmega328p and similar AVR processors. Below is a description of the settings in the configuration file: 18 | 19 | 20 | -Main settings: 21 | 22 | #define polyphony [value] - This definition is responsible for allocating space in the processor's memory. The maximum number of voices played at once is 32, or if enable_highSamplingRate is defined (see below), it is 16. 23 | 24 | #define mode [value] - Variants of used pins. There are 3 output modes: The first mode is one PWM output. The second and third modes are for H-bridge. The second mode is 1 PWM + 2 pins, the third: 2 PWM. 25 | 26 | #define channel [value] - Number of used outputs, with a value of 2 the number of used pins will be doubled, with a value of 1 will remain unchanged. By setting the value to 2 and enabling motor support (enable_motor, description below), you can control their power separately, without this function enabled, the pins and signals will only be copied. 27 | 28 | 29 | -INPUT / OUTPUT SETTINGS: 30 | 31 | #define timerInterrupt [value] - Counter from which interrupts are to be triggered. 3 counters are supported: 0, 1 and 2 (ATmega328p). The selected counter may not work (compile error) if it is used by another library (arduino library uses 0 counter). 32 | 33 | #define PWM1 [value] 34 | #define PWM2 [value] 35 | #define PWM3 [value] 36 | #define PWM4 [value] - Assigns the used PWM. Options: 3, 5, 6, 9, 10, 11. Each PWM changes the settings of the counter (5, 6 - counter 0; 9, 10 - counter 1; 3, 11 - counter 2) and this may cause the program to malfunction if counter is used by another library. PWM and pin values ​​must be different. 37 | 38 | #define pin1 [value] 39 | #define pin2 [value] 40 | #define pin3 [value] 41 | #define pin4 [value] - Assigns the pin used. The range is from 2 to 13. The PWM and pin values ​​must be different. 42 | 43 | 44 | -ADDITIONAL OPTIONS: 45 | 46 | #define disable_volume - Defining this will only cause the volume control to speed up the processor. 47 | 48 | #define disable_secondProgram - Defining this will only double-program, freeing up memory space and speeding up the CPU. The sounds will continue to play in the background. 49 | 50 | #define enable_highSamplingRate - Defining this will improve the audio quality by increasing the audio sampling rate to 31250hz (at 16Mhz clock speed). The CPU load will be doubled. Enabling this option will reduce the number of voices available to 16. When disabled, the sampling rate is: 15625hz and the maximum number of voices is 32. 51 | 52 | #define enable_motor - Defining this will enable engine support. Excluding this option speeds up the processor. 53 | 54 | #define enable_ADC - Defining this will add an automatic ADC reading to adjust the volume. Disabling this option speeds up the processor. 55 | 56 | 57 | 58 | -MANUAL MODE - this mode is for compatibility with other devices based on AVR architecture. To prevent unnecessary rummaging around and changing addresses in the library, it has all been organized here. Each definition must be manually assigned an address corresponding to a given counter or pin. All definitions relating to a specific pin, PWM or counter should be defined (e.g. to define PWM1 one must define C_PWM1_21 and asm_PWM1_21). Don't define the same thing in manual and normal mode. The pins must be set to the output by yourself, and the counters used should be manually set to non-inverting 8-bit Fast-PWM and, if necessary, they should also be synchronized. It is not recommended to use this mode for beginners. 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | MARKING A SECOND PROGRAM 67 | The second program is designed to play music, therefore executing this program has a higher priority than executing a normal program. For both programs to work properly, there must be at least one delay_ms() or delay_ci() command (see below), so that you can return to normal program execution for that time. Otherwise, this program will loop continuously and the normal program will not run. To label this program just write: 68 | 69 | 70 | 71 | start_secondProgram //mark the start of the second program 72 | 73 | //this is where the program should appear 74 | 75 | 76 | delay_ms (1); // there should be a minimum of one delay in the entire program to return to the normal program during that time 77 | 78 | end_secondProgram //mark the end of the second program 79 | 80 | 81 | 82 | 83 | 84 | ADJUSTING THE WAVE SHAPES 85 | The waveforms are set inside the interrupt, write which wave is to be set and then what shape the wave should generate. There are 3 types of waves: square (squareWave()), sawtooth (sawWave()) and triangle (triangleWave()). To mark a break and set the waveforms, just type: 86 | 87 | 88 | 89 | start_interrupt //mark start of interrupt 90 | 91 | //here you define what waves will be used and what shape they should have 92 | 93 | wave01(); //wave 01 should have the shape: 94 | squarewave(); //square shape 95 | 96 | wave02(); //wave 02 should have the shape: 97 | sawWave(); //sawtooth shape 98 | 99 | //and so on... 100 | 101 | wave27(); //wave 27 should have the shape: 102 | triangleWave(); //triangular shape 103 | 104 | end_interrupt //mark end of interrupt 105 | 106 | 107 | 108 | 109 | 110 | WAVE CONTROL 111 | There are 3 functions to control the waves: to change frequency, volume and phase. 112 | 113 | 114 | Change of frequency 115 | To change the frequency of 1 wave, use the wave01_frequency(value) function. To change the frequency of the 2nd wave, use the wave02_frequency(value) function and so on. Additionally, there are 3 functions that enter the appropriate value for the wave: 116 | 117 | -To set the wave to the right frequency use the hz (frequency) function, e.g. wave01_frequency(hz(440)) will set the first wave to 440hz 118 | 119 | -To set the wave to the appropriate sound, you can use the sound names (c4, cs4, d4, ds4, e4, f4, fs4, g4, gs4, a4, as4, b4, c5, cs5, d5 and so on) e.g. wave01_frequency(a4) will set the first wave to the sound frequency a4 120 | 121 | -To set the wave to the appropriate sound, you can use the sound number in the keyboard function (key number), the a4 sound has the number 69 (as in midi), e.g. wave01_frequency(keyboard(69)) will set the first wave to the a4 sound frequency, wave01_frequency(keyboard(48)) will set the first wave to sound c3 122 | 123 | 124 | Change the volume 125 | To change the volume of 1 wave, use the wave01_volume(value) function. To change the volume of the 2nd wave, use the wave02_volume(value) function and so on. The function only takes values ​​from 0 to 255. The sum of the loudness of all waves must not exceed 255 in order not to distort the sound. Additionally, the loudness of the square wave must be twice as low. 126 | 127 | 128 | Phase change 129 | To change the phase of wave 1 of wave, use the wave01_phase(value) function. To change the phase of the 2nd wave, use the wave02_phase(value) function and so on. The function takes the values ​​of int (0-65535). This function is useful for resetting waves. To reset the phase it must be set to 0 or if the wave is triangular (the triangular wave is out of phase) it must be set to 16384 (25%). 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | DESCRIPTION OF THE LIBRARY FUNCTIONS 138 | 139 | 140 | -synthSetup() - configures the microcontroller (sets the pins, counters) 141 | 142 | -hz(frequency) - Converts the frequency and returns the appropriate value for the wave 143 | 144 | -keyboard(key number) 145 | -keyboard(key number, +cents) - this function converts the key number to the appropriate value for the wave, the key number corresponds to the midi number, i.e. the a4 sound has the number 69, you can additionally tune the sounds by adding cents 146 | 147 | -delay_ms(time in milliseconds) - delay after which the return to the music player program is to take place, during the delay the processor returns to the main program execution, this function will be available only if disable_secondProgram is not defined in the configuration file 148 | 149 | -delay_ci(number of interrupts) - the same as delay_ms with the difference that the number of counter interrupts is entered (1 interrupt is 16us at 16Mhz clock speed), during the delay the processor returns to the main program, this function will be available only if not defined in the file configuration configuration disable_secondProgram 150 | 151 | -get_ms() - returns the amount of time in ms 152 | 153 | -get_ci() - returns the number of interrupts of the counter (1 interrupt is 16us at 16Mhz clock speed) 154 | 155 | -pause() - stops playing music (interrupt timer also stops) 156 | 157 | -play() - restart playing music 158 | 159 | -reset() - resets music playback (interrupt timer is also reset) 160 | 161 | -stop() - resets and stops playing music (interrupt timer will be reset and stopped) 162 | 163 | -volume(volume) - sets the volume with which the music is to be played, takes values ​​from 0 to 255, this function will be available only when disable_volume is not defined in the configuration file 164 | 165 | -ADCchannel(ADC pin number) - sets the number of the ADC pin used, this function will be available only when defined in the configuration file enable_ADC 166 | 167 | -motorA(motor A power) - sets the power with which the first motor is to work, takes values ​​from -127 to 127, this function will be available only when defined in the configuration file enable_motor 168 | 169 | -motorB(motor B power) - sets the power with which the second motor is to work, takes values ​​from -127 to 127, this function will be available only when defined in the configuration file enable_motor and channel 2 170 | 171 | 172 | 173 | 174 | 175 | Sample program using the library: 176 | 177 | 178 | #include 179 | 180 | void setup() 181 | { 182 | synthSetup(); //configure the microcontroller 183 | volume(255); //set the master volume to maximum value 184 | 185 | //the volume of all waves must not exceed 255 186 | wave01_volume(64); //the volume of a square wave is counted twice 187 | wave02_volume(127); 188 | 189 | //and so on 190 | 191 | pinMode (13, OUTPUT); 192 | } 193 | 194 | void loop () 195 | { 196 | //some program 197 | digitalWrite (13, HIGH); 198 | delay (1000); 199 | digitalWrite (13, LOW); 200 | delay (1000); 201 | } 202 | 203 | start_interrupt //mark start of interrupt 204 | //define the waves used and their shape 205 | wave01(); 206 | squarewave(); 207 | wave02(); 208 | triangleWave(); 209 | //and so on... 210 | end_interrupt //mark end of interrupt 211 | 212 | start_secondProgram //mark the start of the second program 213 | //some program 214 | wave01_frequency(keyboard (random (45, 93))); 215 | wave02_frequency(keyboard (random (33, 81))); 216 | delay_ms(300); //interrupt this program for 300ms and return to normal program execution during this time 217 | //after completing all tasks, it will return to the beginning of this program 218 | end_secondProgram //mark the end of the second program 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | This is the first version of the library that should be tested, errors may occur (the second program does not have a separate stack and registers are not saved, but the library works faster and there is less memory consumption) but for average use it is rather unlikely. The advantage of this library is speed of work and execution of two programs asynchronously. Disadvantages that could be changed are the configuration file, defining waveforms and others. You can try to expand the synthesizer by adding wave modulations (creating new sounds), reverb, echo, filters but for the first version of the library it is rather enough for now. 227 | 228 | GitHub: https://github.com/ezasm/asmsynth 229 | YouTube: https://www.youtube.com/channel/UCGBqKmF_BD880ZERvZW-lAg -------------------------------------------------------------------------------- /Dokumentacja.txt: -------------------------------------------------------------------------------- 1 | WPROWADZENIE 2 | 3 | 4 | 5 | Biblioteka asmsynth pozwala tworzyć 8-bitową muzykę. Symuluje pracę syntezatora i pozwala generować do 32 głosów. Można wygenerować falę kwadratową, piłokształtną czy trójkątną, najprawdopodobniej zostanie również dodana fala sinusoidalna i szum. Ta biblioteka wprowadza też dwu-programowość, potrafi wykonać asynchronicznie dwa programy jednocześnie tak, aby umożliwić otwarzanie muzyki w tle. Wprowadzona jest obsługa mostka-H, można ten układ wykorzystać jako wzmaczniacz do głośników lub można również sterować pracą silników (i zamiast piszczącego pwm będzie grać melodia :D). 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Konfiguracja biblioteki 14 | 15 | Biblioteka w swoim folderze posiada plik konfiguracyjny (config.h), znajdują się tam wszystkie ustawienia (używane piny, liczniki, tryby pracy biblioteki). Można ten plik edytować za pomocą notatnika. Biblioteka dedykowana dla ATmega328p i podobnych procesorach AVR. Poniżej znajduje się opis ustawień w pliku konfiguracyjnym: 16 | 17 | 18 | -USTAWIENIA GŁÓWNE: 19 | 20 | #define polyphony [wartość] - Ta definicja odpowiada za rezerwowanie miejsca w pamięci procesora. Maksymalna ilość odtwarzanych na raz głosów to 32, lub jeżeli zdefiniowano enable_highSamplingRate (opis poniżej) to 16. 21 | 22 | #define mode [wartość] - Warianty używanych pinów. Dostępne są 3 tryby wyjścia: Pierwszy tryb to jedno wyjście PWM. Drugi i trzeci tryb przeznaczone są do obsługi mostka-H. Drugi tryb to 1 PWM + 2 piny, trzeci: 2 PWM. 23 | 24 | #define channel [wartość] - Ilość używanych wyjść, przy wartości 2 liczba używanych pinów zostanie podwojona, przy wartości 1 zostanie bez zmian. Ustawiając wartość na 2 i włączając obsługę silników (enable_motor, opis poniżej) można sterować osobno ich mocą, bez włączonej tej funkcji piny i sygnały zostaną tylko skopiowane. 25 | 26 | 27 | -USTAWIENIA WEJŚCIA/WYJŚCIA: 28 | 29 | #define timerInterrupt [wartość] - Licznik z którego mają być wyzwalane przerwania. Obsługiwane są 3 liczniki: 0, 1 i 2 (ATmega328p). Wybrany licznik może nie działać (błąd kompilacji) jeśli jest wykorzystywany przez inną bibliotekę (biblioteka arduino korzysta z licznika 0). 30 | 31 | #define PWM1 [wartość] 32 | #define PWM2 [wartość] 33 | #define PWM3 [wartość] 34 | #define PWM4 [wartość] - Przypisuje wykorzystywane PWM. Do wyboru: 3, 5, 6, 9, 10, 11. Każdy PWM zmienia ustawienia licznika (5, 6 - licznik 0; 9, 10 - licznik 1; 3, 11 - licznik 2) i może to spowodować nieprawidłowe działanie programu jeżeli licznik jest wykorzystywany przez inną bibliotekę. Wartości PWM i pinów muszą być różne. 35 | 36 | #define pin1 [wartość] 37 | #define pin2 [wartość] 38 | #define pin3 [wartość] 39 | #define pin4 [wartość] - Przypisuje wykorzystywany pin. Do wyboru przedział od 2 do 13. Wartości PWM i pinów muszą być różne. 40 | 41 | 42 | -DODATKOWE OPCJE: 43 | 44 | #define disable_volume - Zdefiniowanie tego spowoduje wyłącznie funkcji regulacji głośności przyśpieszając pracę procesora. 45 | 46 | #define disable_secondProgram - Zdefiniowanie tego spowoduje wyłącznie dwu-programowości zwalniając miejsce z pamięci i przyśpieszając pracę procesora. Dźwięki będą dalej otwarzane w tle. 47 | 48 | #define enable_highSamplingRate - Zdefiniowanie tego spowoduje poprawę jakości audio zwiększając częstotliwość próbkowania dźwięku do 31250hz (przy taktowaniu 16Mhz). Obciążenie procesora zostanie dwukrotnie zwiększone. Włączenie tej opcji zmniejszy liczbę dostępnych głosów do 16. Przy wyłączonej tej opcji próbkowanie to: 15625hz, a maksymalna liczba głosów to 32. 49 | 50 | #define enable_motor - Zdefiniowanie tego spowoduje włączenie obsługi silników. Wyłącznie tej opcji przyśpiesza pracę procesora. 51 | 52 | #define enable_ADC - Zdefiniowanie tego spowoduje dodanie automatycznego odczytu ADC regulującego głośność. Wyłączenie tej opcji przyśpiesza pracę procesora. 53 | 54 | 55 | 56 | -TRYB RĘCZNY - ten tryb służy do kompatybilności z innymi urządzeniami opartymi na architekturze AVR. Aby zapobiec niepotrzebnemu grzebaniu i zmienianiu adresów w bibliotece zostało to wszystko uporządkowane w tym miejscu. Każdej definicji trzeba ręcznie przypisać adres odpowiadającemu danemu licznikowi czy pinowi. Wszystkie definicje odnoszące się do konkretnego pinu, PWM czy licznika powinny zostać zdefiniowane (np. aby zdefiniować PWM1 trzeba zdefiniować C_PWM1_21 i asm_PWM1_21). Nie należy definiować tej samej rzeczy w trybie ręcznym i normalnym. Piny trzeba samodzielnie ustawić na wyjście, a używane liczniki powinny zostać ręcznie ustawione na non-inverting 8-bit Fast-PWM i jeśli jest taka potrzeba powinny zostać też zsynchronizowane. Nie jest zalecane używanie tego trybu dla początkujących. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | OZNACZANIE DRUGIEGO PROGRAMU 65 | Drugi program przeznaczony jest do otwarzania muzyki dlatego wykonywanie tego programu ma wiekszy priorytet niż wykonywanie zwykłego programu. Aby oba programy działały prawidłowo obowiązkowo musi wystąpić minimum jedna komenda delay_ms() lub delay_ci() (opis poniżej) tak, aby na ten czas powrócić do wykonywania zwykłego programu. W przeciwnym razie ten program będzie odtwarzany cały czas w pętli, a zwykły program nie będzie działać. Aby oznaczyć ten program wystarczy napisać: 66 | 67 | 68 | 69 | start_secondProgram //oznaczenie początku drugiego programu 70 | 71 | //w tym miejscu powinien pojawić się program 72 | 73 | 74 | delay_ms(1); //powinno wystąpić minimum jedno opóźnienie w całym programie aby powrócić na ten czas do zwykłego programu 75 | 76 | end_secondProgram //oznaczenie końca drugiego programu 77 | 78 | 79 | 80 | 81 | 82 | USTAWIANIE KSZTAŁTÓW FAL 83 | Kształty fal ustawiane są wewnątrz przerwania, należy napisać która fala ma być ustawiona a następnie jaki kształt ma generować ta fala. Dostępne są 3 rodzaje fal: kwadratowa (squareWave()), piłokształtna (sawWave()) i trójkątna (triangleWave()). Aby oznaczyć przerwanie i ustawić kształty fal wystarczy napisać: 84 | 85 | 86 | 87 | start_interrupt //oznaczenie początku przerwania 88 | 89 | //w tym miejcu definiuje się jakie fale zostaną użyte i jaki mają mieć kształt 90 | 91 | wave01(); //fala 01 ma mieć kształt: 92 | squareWave(); //kształt kwadratowy 93 | 94 | wave02(); //fala 02 ma mieć kształt: 95 | sawWave(); //kształt piłokształtny 96 | 97 | //i tak dalej... 98 | 99 | wave27(); //fala 27 ma mieć kształt: 100 | triangleWave(); //ksztłt trójkątny 101 | 102 | end_interrupt //oznaczenie końca przerwania 103 | 104 | 105 | 106 | 107 | 108 | STEROWANIE FALAMI 109 | Do sterowania fal są 3 funkcje: do zmiany częstotliwości, głośności i fazy. 110 | 111 | 112 | Zmiana częstotliwości 113 | Aby zmienić częstotliwość 1 fali należy użyć funkcji wave01_frequency(wartość). Aby zmienić częstotliwość 2 fali należy użyć funkcji wave02_frequency(wartość) i tak dalej. Dodatkowo są 3 funkcje które wpisują odpowiednią wartość dla fali: 114 | 115 | -Aby ustawić falę na odpowiednią częstotliwośc należy użyć funkcji hz(częstotliwośc) np. wave01_frequency(hz(440)) ustawi pierwszą falę na częstotliwość 440hz 116 | 117 | -Aby ustawić falę na odpowiedni dźwięk można użyć nazw dźwięku (c4, cs4, d4, ds4, e4, f4, fs4, g4, gs4, a4, as4, b4, c5, cs5, d5 i tak dalej) np. wave01_frequency(a4) ustawi pierwszą fale na częstotliwość dźwięku a4 118 | 119 | -Aby ustawić falę na odpowiedni dźwięk można użyć numeru dźwięku w funkcji keyboard(numer klawisza), dźwięk a4 ma numer 69 (tak jak w midi), np. wave01_frequency(keyboard(69)) ustawi pierwszą fale na częstotliwość dźwięku a4, wave01_frequency(keyboard(48)) ustawi pierwszą falę na dźwięk c3 120 | 121 | 122 | Zmiana głośności 123 | Aby zmienić głośnośc 1 fali należy użyć funkcji wave01_volume(wartość). Aby zmienić głośność 2 fali należy użyć funkcji wave02_volume(wartość) i tak dalej. Funkcja przyjmuje tylko wartości od 0 do 255. Suma głośności wszystkich fal nie może przekraczać 255 aby nie przesterować dźwięku. Dodatkowo głośność fali kwadratowej musi być dwukrotnie mniejsza. 124 | 125 | 126 | Zmiana fazy 127 | Aby zmienić fazę fali 1 fali należy użyć funkcji wave01_phase(wartość). Aby zmienić fazę 2 fali należy użyć funkcji wave02_phase(wartość) i tak dalej. Funkcja przyjmuje wartości int (0-65535). Funkcja jest przydatna do resetowania fal. Aby zresetować fazę trzeba ustawic ją na 0 lub jeżeli fala jest trójkątna (fala trójkątna ma przesuniętą fazę) to trzeba ustawić fazę na 16384 (25%). 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | OPIS FUNKCJI BIBLIOTEKI 136 | 137 | 138 | -synthSetup() - konfiguruje mikrokontroler (ustawia piny, liczniki) 139 | 140 | -hz(częstotliwość) - przelicza częstotliwość i zwraca odpowiednią wartość dla fali 141 | 142 | -keyboard(numer klawisza) 143 | -keyboard(numer klawisza, +centy) - ta funkcja przelicza numer klawisza na odpowiednią wartość dla fali, numer klawisza odpowiada numerowi midi czyli dźwięk a4 ma numer 69, można dodatkowo stroić dźwięki dodając centy 144 | 145 | -delay_ms(czas w milisekundach) - opóźnienie po jakim czasie ma nastąpić powrót do programu odtwarzającego muzykę, podczas opóźnienia procesor wraca do wykonywania głównego programu, ta funkcja będzie dostępna tylko wtedy gdy nie zdefiniowano w pilku konfiguracyjnym disable_secondProgram 146 | 147 | -delay_ci(ilośc przerwań) - tak samo jak delay_ms z tą różnicą że wpisuje się ilość przerwań licznika (1 przerwanie to 16us przy taktowaniu 16Mhz), podczas opóźnienia procesor wraca do wykonywania głównego programu, ta funkcja będzie dostępna tylko wtedy gdy nie zdefiniowano w pilku konfiguracyjnym disable_secondProgram 148 | 149 | -get_ms() - zwraca ilość czasu w ms 150 | 151 | -get_ci() - zwraca ilość przerwań licznika (1 przerwanie to 16us przy taktowaniu 16Mhz) 152 | 153 | -pause() - zatrzymuje odtwarzanie muzyki (licznik przerwań również zostaje zatrzymany) 154 | 155 | -play() - ponowne włączenie odtwarzanie muzyki 156 | 157 | -reset() - resetuje odtwarzanie muzyki (licznik przerwań również zostaje zresetowany) 158 | 159 | -stop() - resetuje i zatrzymuje odtwarzanie muzyki (licznik przerwań zostanie zresetowany i zatrzymany) 160 | 161 | -volume(głośność) - ustawia głośność z jaką ma być odtwarzana muzyka, przyjmuje wartości od 0 do 255, ta funkcja będzie dostępna tylko wtedy gdy nie zdefiniowano w pilku konfiguracyjnym disable_volume 162 | 163 | -ADCchannel(numer pinu ADC) - ustawia numer używanego pinu ADC, ta funkcja będzie dostępna tylko wtedy gdy zdefiniowano w pilku konfiguracyjnym enable_ADC 164 | 165 | -motorA(moc silnika A) - ustawia moc z jaką ma pracować pierwszy silnik, przyjmuje wartości od -127 do 127, ta funkcja będzie dostępna tylko wtedy gdy zdefiniowano w pilku konfiguracyjnym enable_motor 166 | 167 | -motorB(moc silnika B) - ustawia moc z jaką ma pracować drugi silnik, przyjmuje wartości od -127 do 127, ta funkcja będzie dostępna tylko wtedy gdy zdefiniowano w pilku konfiguracyjnym enable_motor i channel 2 168 | 169 | 170 | 171 | 172 | 173 | Przykładowy program z użyciem biblioteki: 174 | 175 | 176 | #include 177 | 178 | void setup() 179 | { 180 | synthSetup(); //konfigurowanie mikrokontrolera 181 | volume(255); //ustawienie głównej głośności na maksymalną wartość 182 | 183 | //poziom głośności wszystkich fal nie może przekraczać 255 184 | wave01_volume(64); //głośność fali kwadratowej liczona jest podwójnie 185 | wave02_volume(127); 186 | 187 | //i tak dalej 188 | 189 | pinMode(13, OUTPUT); 190 | } 191 | 192 | void loop() 193 | { 194 | //jakiś program 195 | digitalWrite(13, HIGH); 196 | delay(1000); 197 | digitalWrite(13, LOW); 198 | delay(1000); 199 | } 200 | 201 | start_interrupt //oznaczenie początku przerwania 202 | //określanie użytych fal i ich kształtu 203 | wave01(); 204 | squareWave(); 205 | wave02(); 206 | triangleWave(); 207 | //i tak dalej... 208 | end_interrupt //oznaczenie końca przerwania 209 | 210 | start_secondProgram //oznaczenie początku drugiego programu 211 | //jakiś program 212 | wave01_frequency(keyboard(random(45, 93))); 213 | wave02_frequency(keyboard(random(33, 81))); 214 | delay_ms(300); //przerwanie tego programu na 300ms i powrót na ten czas do wykonywania zwykłego programu 215 | //po skończeniu wszystkich zadań nastąpi powrót do początku tego programu 216 | end_secondProgram //oznaczenie końca drugiego programu 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | Jest to pierwsza wersja biblioteki którą należy przetestować, mogą pojawić się błędy (drugi program nie posiada osobnego stosu i rejestry nie są zapisywane, ale za to biblioteka działa szybciej i jest mniejsze użycie pamięci) chodź dla przeciętnego użytkowania to raczej mało prawdopodobne. Zaletą tej biblioteki jest szybkość pracy i wykonywanie asynchronicznie dwóch programów na raz. Wady które można by było zmienić to plik konfiguracyjny czy definiowanie kształtów fal i inne. Można spróbować rozbudować syntezator dodając modulacje fal (tworząc nowe brzmienia), pogłos, echo, filtry ale na pierszą wersję biblioteki to raczej narazie wystarczy. 225 | 226 | GitHub: https://github.com/ezasm/asmsynth 227 | YouTube: https://www.youtube.com/channel/UCGBqKmF_BD880ZERvZW-lAg -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Paweł Sokół 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /examples/JSBach_Toccata-d/JSBach_Toccata-d.ino: -------------------------------------------------------------------------------- 1 | //requirements: 2 | //11 voices 3 | //13kb +/- program memory 4 | 5 | 6 | #include 7 | volatile byte counter; 8 | 9 | void setup() 10 | { 11 | synthSetup(); 12 | pinMode(13, OUTPUT); 13 | } 14 | 15 | void loop() 16 | { 17 | digitalWrite(13, HIGH); 18 | delay(500); 19 | digitalWrite(13, LOW); 20 | delay(500); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | start_interrupt 28 | wave01(); 29 | squareWave(); 30 | 31 | wave02(); 32 | squareWave(); 33 | 34 | wave03(); 35 | squareWave(); 36 | 37 | wave04(); 38 | squareWave(); 39 | 40 | wave05(); 41 | squareWave(); 42 | 43 | wave06(); 44 | squareWave(); 45 | 46 | wave07(); 47 | squareWave(); 48 | 49 | wave08(); 50 | squareWave(); 51 | 52 | wave09(); 53 | sawWave(); 54 | 55 | wave10(); 56 | sawWave(); 57 | 58 | wave11(); 59 | triangleWave(); 60 | end_interrupt 61 | 62 | 63 | 64 | 65 | 66 | void stop01() 67 | { 68 | wave01_volume(0); 69 | wave01_frequency(0); 70 | wave01_phase(0); 71 | } 72 | 73 | void stop02() 74 | { 75 | wave02_volume(0); 76 | wave02_frequency(0); 77 | wave02_phase(0); 78 | } 79 | 80 | void stop03() 81 | { 82 | wave03_volume(0); 83 | wave03_frequency(0); 84 | wave03_phase(0); 85 | } 86 | 87 | void stop04() 88 | { 89 | wave04_volume(0); 90 | wave04_frequency(0); 91 | wave04_phase(0); 92 | } 93 | 94 | void stop05() 95 | { 96 | wave05_volume(0); 97 | wave05_frequency(0); 98 | wave05_phase(0); 99 | } 100 | 101 | void stop06() 102 | { 103 | wave06_volume(0); 104 | wave06_frequency(0); 105 | wave06_phase(0); 106 | } 107 | 108 | void stop07() 109 | { 110 | wave07_volume(0); 111 | wave07_frequency(0); 112 | wave07_phase(0); 113 | } 114 | 115 | void stop08() 116 | { 117 | wave08_volume(0); 118 | wave08_frequency(0); 119 | wave08_phase(0); 120 | } 121 | 122 | void stop09() 123 | { 124 | wave09_volume(0); 125 | wave09_frequency(0); 126 | wave09_phase(0); 127 | } 128 | 129 | void stop10() 130 | { 131 | wave10_volume(0); 132 | wave10_frequency(0); 133 | wave10_phase(0); 134 | } 135 | 136 | void stop11() 137 | { 138 | wave11_volume(0); 139 | wave11_frequency(0); 140 | wave11_phase(1<<14); 141 | } 142 | 143 | 144 | 145 | 146 | void voice01(unsigned int a) 147 | { 148 | cli(); 149 | wave09_frequency(a); 150 | wave01_frequency(a<<1); 151 | sei(); 152 | } 153 | 154 | void voice01v() 155 | { 156 | //wave01_phase(1<<13); 157 | wave01_volume(85);//65 158 | wave09_volume(160);//123 159 | } 160 | 161 | void voice01s() 162 | { 163 | stop01(); 164 | stop09(); 165 | } 166 | 167 | 168 | 169 | inline void voice02(unsigned int a) __attribute__((always_inline)); 170 | void voice02(unsigned int a) 171 | { 172 | wave09_frequency(a); 173 | wave10_frequency(a*0.997); 174 | } 175 | 176 | void voice02v() 177 | { 178 | wave09_volume(127); 179 | wave10_volume(127); 180 | } 181 | 182 | void voice02s() 183 | { 184 | stop09(); 185 | stop10(); 186 | } 187 | 188 | 189 | 190 | void voice03(unsigned int a) 191 | { 192 | if(counter==0) 193 | wave09_frequency(a>>1); 194 | else 195 | wave01_frequency(a); 196 | } 197 | 198 | 199 | 200 | void voice04(unsigned int a) 201 | { 202 | byte i=counter; 203 | while(i!=0) 204 | { 205 | a=a>>1; 206 | i=i-1; 207 | } 208 | wave01_frequency(a); 209 | } 210 | 211 | 212 | 213 | start_secondProgram 214 | voice01v(); 215 | voice01(a4); 216 | delay_ms(100); 217 | 218 | voice01(g4); 219 | delay_ms(100); 220 | 221 | voice01(a4); 222 | delay_ms(1500); 223 | 224 | voice01s(); 225 | delay_ms(1500); 226 | 227 | 228 | 229 | voice01v(); 230 | voice01(g4); 231 | delay_ms(225); 232 | 233 | voice01(f4); 234 | delay_ms(150); 235 | 236 | voice01(e4); 237 | delay_ms(135); 238 | 239 | voice01(d4); 240 | delay_ms(125); 241 | 242 | voice01(cs4); 243 | delay_ms(650); 244 | 245 | voice01(d4); 246 | delay_ms(1500); 247 | 248 | voice01s(); 249 | delay_ms(2000); 250 | 251 | 252 | 253 | 254 | voice02v(); 255 | voice02(a3); 256 | delay_ms(100); 257 | 258 | voice02(g3); 259 | delay_ms(100); 260 | 261 | voice02(a3); 262 | delay_ms(1500); 263 | 264 | voice02s(); 265 | delay_ms(1000); 266 | 267 | voice02v(); 268 | voice02(e3); 269 | delay_ms(400); 270 | 271 | voice02(f3); 272 | delay_ms(350); 273 | 274 | voice02(cs3); 275 | delay_ms(450); 276 | 277 | voice02(d3); 278 | delay_ms(1500); 279 | 280 | voice02s(); 281 | delay_ms(2000); 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | voice01v(); 291 | voice01(a2); 292 | delay_ms(100); 293 | 294 | voice01(g2); 295 | delay_ms(100); 296 | 297 | voice01(a2); 298 | delay_ms(1500); 299 | 300 | voice01s(); 301 | delay_ms(1500); 302 | 303 | 304 | 305 | voice01v(); 306 | voice01(g2); 307 | delay_ms(155); 308 | 309 | voice01(f2); 310 | delay_ms(140); 311 | 312 | voice01(e2); 313 | delay_ms(130); 314 | 315 | voice01(d2); 316 | delay_ms(125); 317 | 318 | voice01(cs2); 319 | delay_ms(650); 320 | 321 | voice01(d2); 322 | delay_ms(1500); 323 | 324 | voice01s(); 325 | delay_ms(2000); 326 | 327 | 328 | 329 | 330 | wave09_volume(255); 331 | wave09_frequency(d1); 332 | delay_ms(2000); 333 | 334 | wave09_volume(191); 335 | wave01_volume(31); 336 | wave01_frequency(cs3); 337 | delay_ms(750); 338 | 339 | wave09_volume(151); 340 | wave01_volume(25); 341 | wave02_volume(25); 342 | wave02_frequency(e3); 343 | delay_ms(700); 344 | 345 | wave09_volume(123); 346 | wave01_volume(21); 347 | wave02_volume(21); 348 | wave03_volume(21); 349 | wave03_frequency(g3); 350 | delay_ms(650); 351 | 352 | wave09_volume(103); 353 | wave01_volume(18); 354 | wave02_volume(18); 355 | wave03_volume(18); 356 | wave04_volume(18); 357 | wave04_frequency(as3); 358 | delay_ms(800); 359 | 360 | wave09_volume(95); 361 | wave01_volume(15); 362 | wave02_volume(15); 363 | wave03_volume(15); 364 | wave04_volume(15); 365 | wave05_volume(15); 366 | wave05_frequency(cs4); 367 | delay_ms(1000); 368 | 369 | wave09_volume(75); 370 | wave01_volume(14); 371 | wave02_volume(14); 372 | wave03_volume(14); 373 | wave04_volume(14); 374 | wave05_volume(14); 375 | wave06_volume(14); 376 | wave06_frequency(e4); 377 | delay_ms(1500); 378 | 379 | 380 | 381 | 382 | wave09_volume(121); 383 | wave01_volume(14); 384 | stop02(); 385 | wave03_volume(20); 386 | wave04_volume(14); 387 | wave05_volume(14); 388 | stop06(); 389 | wave01_frequency(d3); 390 | wave04_frequency(a3); 391 | wave05_frequency(d4); 392 | delay_ms(1000); 393 | 394 | wave03_frequency(e3); 395 | delay_ms(1500); 396 | 397 | wave03_frequency(fs3); 398 | delay_ms(3000); 399 | 400 | 401 | 402 | 403 | 404 | 405 | stop01(); 406 | stop03(); 407 | stop04(); 408 | stop05(); 409 | stop09(); 410 | delay_ms(2000); 411 | 412 | 413 | 414 | wave09_volume(150); 415 | 416 | counter=0; 417 | while(counter!=2) 418 | { 419 | voice03(cs5); 420 | delay_ms(300); 421 | 422 | voice03(d5); 423 | delay_ms(220); 424 | 425 | voice03(e5); 426 | delay_ms(150); 427 | 428 | voice03(cs5); 429 | delay_ms(130); 430 | 431 | voice03(d5); 432 | delay_ms(120); 433 | 434 | voice03(e5); 435 | delay_ms(120); 436 | 437 | voice03(cs5); 438 | delay_ms(120); 439 | 440 | voice03(d5); 441 | delay_ms(120); 442 | 443 | voice03(e5); 444 | delay_ms(130); 445 | 446 | voice03(cs5); 447 | delay_ms(150); 448 | 449 | voice03(d5); 450 | delay_ms(220); 451 | 452 | voice03(e5); 453 | delay_ms(300); 454 | 455 | voice03(f5); 456 | delay_ms(220); 457 | 458 | voice03(g5); 459 | delay_ms(150); 460 | 461 | voice03(e5); 462 | delay_ms(130); 463 | 464 | voice03(f5); 465 | delay_ms(120); 466 | 467 | voice03(g5); 468 | delay_ms(120); 469 | 470 | voice03(e5); 471 | delay_ms(120); 472 | 473 | voice03(f5); 474 | delay_ms(120); 475 | 476 | voice03(g5); 477 | delay_ms(130); 478 | 479 | voice03(e5); 480 | delay_ms(150); 481 | 482 | voice03(f5); 483 | delay_ms(220); 484 | 485 | voice03(g5); 486 | delay_ms(300); 487 | 488 | voice03(a5); 489 | delay_ms(220); 490 | 491 | voice03(as5); 492 | delay_ms(150); 493 | 494 | voice03(g5); 495 | delay_ms(130); 496 | 497 | voice03(a5); 498 | delay_ms(120); 499 | 500 | voice03(as5); 501 | delay_ms(120); 502 | 503 | voice03(g5); 504 | delay_ms(120); 505 | 506 | voice03(a5); 507 | delay_ms(140); 508 | 509 | voice03(as5); 510 | delay_ms(200); 511 | 512 | voice03(g5); 513 | delay_ms(300); 514 | 515 | voice03(a5); 516 | delay_ms(1000); 517 | 518 | voice01s(); 519 | delay_ms(2000); 520 | 521 | counter=counter+1; 522 | wave01_volume(75); 523 | } 524 | 525 | 526 | 527 | 528 | voice01v(); 529 | voice01(a4); 530 | delay_ms(350); 531 | 532 | voice01(g4); 533 | delay_ms(250); 534 | 535 | voice01(as4); 536 | delay_ms(200); 537 | 538 | voice01(e4); 539 | delay_ms(170); 540 | 541 | voice01(g4); 542 | delay_ms(150); 543 | 544 | voice01(as4); 545 | delay_ms(135); 546 | 547 | voice01(e4); 548 | delay_ms(125); 549 | 550 | voice01(f4); 551 | delay_ms(120); 552 | 553 | voice01(a4); 554 | delay_ms(115); 555 | 556 | voice01(d4); 557 | delay_ms(110); 558 | 559 | voice01(f4); 560 | delay_ms(110); 561 | 562 | voice01(a4); 563 | delay_ms(110); 564 | 565 | voice01(d4); 566 | delay_ms(110); 567 | 568 | voice01(e4); 569 | delay_ms(110); 570 | 571 | voice01(g4); 572 | delay_ms(110); 573 | 574 | voice01(c4); 575 | delay_ms(110); 576 | 577 | voice01(e4); 578 | delay_ms(110); 579 | 580 | voice01(g4); 581 | delay_ms(110); 582 | 583 | voice01(c4); 584 | delay_ms(110); 585 | 586 | voice01(d4); 587 | delay_ms(110); 588 | 589 | voice01(f4); 590 | delay_ms(110); 591 | 592 | voice01(as3); 593 | delay_ms(110); 594 | 595 | voice01(d4); 596 | delay_ms(110); 597 | 598 | voice01(f4); 599 | delay_ms(110); 600 | 601 | voice01(as3); 602 | delay_ms(110); 603 | 604 | voice01(c4); 605 | delay_ms(110); 606 | 607 | voice01(e4); 608 | delay_ms(110); 609 | 610 | voice01(a3); 611 | delay_ms(110); 612 | 613 | voice01(c4); 614 | delay_ms(110); 615 | 616 | voice01(e4); 617 | delay_ms(110); 618 | 619 | voice01(a3); 620 | delay_ms(110); 621 | 622 | voice01(as3); 623 | delay_ms(110); 624 | 625 | voice01(d4); 626 | delay_ms(110); 627 | 628 | voice01(g3); 629 | delay_ms(110); 630 | 631 | voice01(as3); 632 | delay_ms(110); 633 | 634 | voice01(d4); 635 | delay_ms(110); 636 | 637 | voice01(g3); 638 | delay_ms(110); 639 | 640 | voice01(a3); 641 | delay_ms(110); 642 | 643 | voice01(c4); 644 | delay_ms(110); 645 | 646 | voice01(f3); 647 | delay_ms(110); 648 | 649 | voice01(a3); 650 | delay_ms(110); 651 | 652 | voice01(c4); 653 | delay_ms(110); 654 | 655 | voice01(f3); 656 | delay_ms(110); 657 | 658 | voice01(g3); 659 | delay_ms(110); 660 | 661 | voice01(as3); 662 | delay_ms(110); 663 | 664 | voice01(e3); 665 | delay_ms(110); 666 | 667 | voice01(g3); 668 | delay_ms(110); 669 | 670 | voice01(as3); 671 | delay_ms(110); 672 | 673 | voice01(e3); 674 | delay_ms(110); 675 | 676 | voice01(f3); 677 | delay_ms(110); 678 | 679 | voice01(a3); 680 | delay_ms(110); 681 | 682 | voice01(d3); 683 | delay_ms(110); 684 | 685 | voice01(f3); 686 | delay_ms(110); 687 | 688 | voice01(a3); 689 | delay_ms(110); 690 | 691 | voice01(d3); 692 | delay_ms(115); 693 | 694 | voice01(e3); 695 | delay_ms(125); 696 | 697 | voice01(g3); 698 | delay_ms(135); 699 | 700 | voice01(cs3); 701 | delay_ms(150); 702 | 703 | voice01(e3); 704 | delay_ms(170); 705 | 706 | voice01(g3); 707 | delay_ms(200); 708 | 709 | voice01(cs3); 710 | delay_ms(700); 711 | 712 | 713 | voice01s(); 714 | wave09_frequency(d1); 715 | wave09_volume(255); 716 | delay_ms(1500); 717 | 718 | counter=255; 719 | while(counter>62) 720 | { 721 | wave09_volume(counter); 722 | counter=counter-1; 723 | delay_ms(1); 724 | } 725 | 726 | wave01_volume(11); 727 | wave02_volume(11); 728 | wave03_volume(11); 729 | wave04_volume(11); 730 | wave05_volume(11); 731 | wave06_volume(11); 732 | wave07_volume(11); 733 | wave08_volume(11); 734 | wave01_frequency(as4); 735 | wave02_frequency(g4); 736 | wave03_frequency(e4); 737 | wave04_frequency(cs4); 738 | wave05_frequency(as3); 739 | wave06_frequency(g3); 740 | wave07_frequency(e3); 741 | wave08_frequency(cs3); 742 | delay_ms(3000); 743 | 744 | stop02(); 745 | stop03(); 746 | stop04(); 747 | stop05(); 748 | stop06(); 749 | stop07(); 750 | stop08(); 751 | stop09(); 752 | 753 | 754 | counter=11; 755 | while(counter<75) 756 | { 757 | counter=counter+1; 758 | wave01_volume(counter); 759 | delay_ms(1); 760 | } 761 | 762 | delay_ms(1200); 763 | 764 | wave01_frequency(a4); 765 | delay_ms(400); 766 | 767 | wave01_frequency(g4); 768 | delay_ms(250); 769 | 770 | wave01_frequency(f4); 771 | delay_ms(200); 772 | 773 | wave01_frequency(e4); 774 | delay_ms(200); 775 | 776 | wave01_frequency(d4); 777 | delay_ms(200); 778 | 779 | wave01_frequency(cs4); 780 | delay_ms(200); 781 | 782 | wave01_frequency(h3); 783 | delay_ms(220); 784 | 785 | wave01_frequency(cs4); 786 | delay_ms(250); 787 | 788 | wave01_frequency(a3); 789 | delay_ms(250); 790 | 791 | wave01_frequency(cs4); 792 | delay_ms(220); 793 | 794 | wave01_frequency(e4); 795 | delay_ms(200); 796 | 797 | wave01_frequency(g4); 798 | delay_ms(300); 799 | 800 | wave01_frequency(f4); 801 | delay_ms(200); 802 | 803 | 804 | counter=0; 805 | while(counter<9) 806 | { 807 | byte a=counter; 808 | a=a&1; 809 | if(a==1) 810 | wave01_frequency(f4); 811 | else 812 | wave01_frequency(g4); 813 | counter=counter+1; 814 | delay_ms(80); 815 | } 816 | 817 | wave01_frequency(f4); 818 | delay_ms(300); 819 | 820 | wave01_frequency(e4); 821 | delay_ms(600); 822 | 823 | 824 | counter=75; 825 | while(counter>23) 826 | { 827 | counter=counter-1; 828 | wave01_volume(counter); 829 | delay_ms(1); 830 | } 831 | 832 | 833 | wave02_volume(13); 834 | wave03_volume(13); 835 | wave04_volume(13); 836 | wave05_volume(13); 837 | wave09_volume(95); 838 | wave09_frequency(d1); 839 | wave01_frequency(f4); 840 | wave02_frequency(d4); 841 | wave03_frequency(a3); 842 | wave04_frequency(f3); 843 | wave05_frequency(d3); 844 | delay_ms(3000); 845 | 846 | stop01(); 847 | stop02(); 848 | stop03(); 849 | stop04(); 850 | stop05(); 851 | stop09(); 852 | delay_ms(1000); 853 | 854 | 855 | wave01_volume(75); 856 | wave01_frequency(a4); 857 | delay_ms(200); 858 | counter=0; 859 | while(counter!=2) 860 | { 861 | 862 | wave01_frequency(d5); 863 | delay_ms(120); 864 | 865 | wave01_frequency(a4); 866 | delay_ms(120); 867 | 868 | wave01_frequency(e5); 869 | delay_ms(120); 870 | 871 | wave01_frequency(a4); 872 | delay_ms(120); 873 | 874 | wave01_frequency(f5); 875 | delay_ms(120); 876 | 877 | wave01_frequency(a4); 878 | delay_ms(120); 879 | counter=counter+1; 880 | } 881 | 882 | wave01_frequency(g5); 883 | delay_ms(120); 884 | 885 | wave01_frequency(a4); 886 | delay_ms(120); 887 | 888 | wave01_frequency(e5); 889 | delay_ms(120); 890 | 891 | counter=0; 892 | while(counter!=2) 893 | { 894 | wave01_frequency(a4); 895 | delay_ms(120); 896 | 897 | wave01_frequency(f5); 898 | delay_ms(120); 899 | 900 | wave01_frequency(a4); 901 | delay_ms(120); 902 | 903 | wave01_frequency(g5); 904 | delay_ms(120); 905 | 906 | wave01_frequency(a4); 907 | delay_ms(120); 908 | 909 | wave01_frequency(a5); 910 | delay_ms(120); 911 | counter=counter+1; 912 | } 913 | 914 | counter=0; 915 | goto skip1; 916 | while(counter!=3) 917 | { 918 | wave01_frequency(a4); 919 | delay_ms(120); 920 | 921 | voice04(a5); 922 | delay_ms(120); 923 | 924 | skip1: 925 | wave01_frequency(a4); 926 | delay_ms(120); 927 | 928 | voice04(as5); 929 | delay_ms(120); 930 | 931 | wave01_frequency(a4); 932 | delay_ms(120); 933 | 934 | voice04(g5); 935 | delay_ms(120); 936 | 937 | wave01_frequency(a4); 938 | delay_ms(120); 939 | 940 | voice04(a5); 941 | delay_ms(120); 942 | 943 | wave01_frequency(a4); 944 | delay_ms(120); 945 | 946 | voice04(f5); 947 | delay_ms(120); 948 | 949 | wave01_frequency(a4); 950 | delay_ms(120); 951 | 952 | voice04(g5); 953 | delay_ms(120); 954 | 955 | wave01_frequency(a4); 956 | delay_ms(120); 957 | 958 | voice04(e5); 959 | delay_ms(120); 960 | 961 | wave01_frequency(a4); 962 | delay_ms(120); 963 | 964 | voice04(f5); 965 | delay_ms(120); 966 | 967 | wave01_frequency(a4); 968 | delay_ms(120); 969 | 970 | voice04(d5); 971 | delay_ms(120); 972 | 973 | wave01_frequency(a4); 974 | delay_ms(120); 975 | 976 | if(counter!=0) 977 | { 978 | voice04(g5); 979 | delay_ms(120); 980 | 981 | wave01_frequency(a4); 982 | delay_ms(120); 983 | 984 | voice04(e5); 985 | delay_ms(120); 986 | 987 | wave01_frequency(a4); 988 | delay_ms(120); 989 | 990 | voice04(f5); 991 | delay_ms(120); 992 | 993 | wave01_frequency(a4); 994 | delay_ms(120); 995 | 996 | voice04(d5); 997 | delay_ms(120); 998 | 999 | wave01_frequency(a4); 1000 | delay_ms(120); 1001 | } 1002 | 1003 | 1004 | voice04(e5); 1005 | delay_ms(120); 1006 | 1007 | wave01_frequency(a4); 1008 | delay_ms(120); 1009 | 1010 | voice04(cs5); 1011 | delay_ms(120); 1012 | 1013 | wave01_frequency(a4); 1014 | delay_ms(120); 1015 | 1016 | voice04(d5); 1017 | delay_ms(120); 1018 | counter=counter+1; 1019 | } 1020 | delay_ms(390); 1021 | 1022 | stop01(); 1023 | delay_ms(390); 1024 | 1025 | 1026 | counter=0; 1027 | while(counter!=2) 1028 | { 1029 | wave11_volume(255); 1030 | wave11_frequency(d4); 1031 | delay_ms(120); 1032 | 1033 | wave11_frequency(f4); 1034 | delay_ms(120); 1035 | 1036 | wave11_frequency(as4); 1037 | delay_ms(120); 1038 | 1039 | wave11_frequency(f4); 1040 | delay_ms(120); 1041 | 1042 | wave11_frequency(c4); 1043 | delay_ms(120); 1044 | 1045 | wave11_frequency(e4); 1046 | delay_ms(120); 1047 | 1048 | wave11_frequency(a4); 1049 | delay_ms(120); 1050 | 1051 | wave11_frequency(e4); 1052 | delay_ms(120); 1053 | 1054 | wave11_frequency(as3); 1055 | delay_ms(120); 1056 | 1057 | wave11_frequency(d4); 1058 | delay_ms(120); 1059 | 1060 | wave11_frequency(g4); 1061 | delay_ms(120); 1062 | 1063 | wave11_frequency(d4); 1064 | delay_ms(120); 1065 | 1066 | wave11_frequency(a3); 1067 | delay_ms(120); 1068 | 1069 | wave11_frequency(cs4); 1070 | delay_ms(120); 1071 | 1072 | wave11_frequency(e4); 1073 | delay_ms(120); 1074 | 1075 | wave11_frequency(a4); 1076 | delay_ms(150); 1077 | 1078 | stop11(); 1079 | wave09_volume(103); 1080 | wave01_volume(18); 1081 | wave09_frequency(d2); 1082 | wave01_frequency(d4); 1083 | delay_ms(270); 1084 | 1085 | wave02_volume(18); 1086 | wave03_volume(18); 1087 | wave02_frequency(f4); 1088 | wave03_frequency(as4); 1089 | delay_ms(300); 1090 | 1091 | stop02(); 1092 | stop03(); 1093 | wave09_frequency(c2); 1094 | wave01_frequency(a3); 1095 | delay_ms(315); 1096 | 1097 | wave02_volume(18); 1098 | wave03_volume(18); 1099 | wave02_frequency(e4); 1100 | wave03_frequency(a4); 1101 | delay_ms(340); 1102 | 1103 | stop02(); 1104 | stop03(); 1105 | wave09_frequency(as1); 1106 | wave01_frequency(as3); 1107 | delay_ms(350); 1108 | 1109 | wave02_volume(18); 1110 | wave03_volume(18); 1111 | wave02_frequency(d4); 1112 | wave03_frequency(g4); 1113 | delay_ms(400); 1114 | 1115 | wave04_volume(18); 1116 | wave09_frequency(a1); 1117 | wave01_frequency(a4); 1118 | wave02_frequency(e4); 1119 | wave03_frequency(cs4); 1120 | wave04_frequency(e3); 1121 | delay_ms(1000); 1122 | 1123 | if (counter!=1) stop01(); 1124 | stop02(); 1125 | stop03(); 1126 | stop04(); 1127 | stop09(); 1128 | counter=counter+1; 1129 | } 1130 | 1131 | counter=18; 1132 | while(counter<75) 1133 | { 1134 | counter=counter+1; 1135 | wave01_volume(counter); 1136 | delay_ms(1); 1137 | } 1138 | delay_ms(600); 1139 | 1140 | wave01_frequency(g4); 1141 | delay_ms(250); 1142 | 1143 | wave01_frequency(f4); 1144 | delay_ms(200); 1145 | 1146 | wave01_frequency(e4); 1147 | delay_ms(150); 1148 | 1149 | wave01_frequency(d4); 1150 | delay_ms(120); 1151 | 1152 | wave01_frequency(cs4); 1153 | delay_ms(110); 1154 | 1155 | wave01_frequency(h3); 1156 | delay_ms(120); 1157 | 1158 | wave01_frequency(cs4); 1159 | delay_ms(150); 1160 | 1161 | wave01_frequency(a3); 1162 | delay_ms(130); 1163 | 1164 | wave01_frequency(h3); 1165 | delay_ms(120); 1166 | 1167 | wave01_frequency(cs4); 1168 | delay_ms(110); 1169 | 1170 | wave01_frequency(d4); 1171 | delay_ms(110); 1172 | 1173 | wave01_frequency(e4); 1174 | delay_ms(110); 1175 | 1176 | wave01_frequency(f4); 1177 | delay_ms(110); 1178 | 1179 | wave01_frequency(g4); 1180 | delay_ms(110); 1181 | 1182 | wave01_frequency(a4); 1183 | delay_ms(110); 1184 | 1185 | wave01_frequency(g4); 1186 | delay_ms(110); 1187 | 1188 | wave01_frequency(f4); 1189 | delay_ms(110); 1190 | 1191 | wave01_frequency(e4); 1192 | delay_ms(110); 1193 | 1194 | wave01_frequency(f4); 1195 | delay_ms(110); 1196 | 1197 | wave01_frequency(d4); 1198 | delay_ms(110); 1199 | 1200 | wave01_frequency(f4); 1201 | delay_ms(110); 1202 | 1203 | wave01_frequency(a4); 1204 | delay_ms(110); 1205 | 1206 | wave01_frequency(cs5); 1207 | delay_ms(110); 1208 | 1209 | wave01_frequency(d5); 1210 | delay_ms(200); 1211 | 1212 | wave01_frequency(a4); 1213 | delay_ms(150); 1214 | 1215 | wave01_frequency(h4); 1216 | delay_ms(120); 1217 | 1218 | wave01_frequency(cs5); 1219 | delay_ms(110); 1220 | 1221 | wave01_frequency(d5); 1222 | delay_ms(110); 1223 | 1224 | wave01_frequency(e5); 1225 | delay_ms(110); 1226 | 1227 | wave01_frequency(f5); 1228 | delay_ms(110); 1229 | 1230 | wave01_frequency(g5); 1231 | delay_ms(110); 1232 | 1233 | wave01_frequency(a5); 1234 | delay_ms(110); 1235 | 1236 | wave01_frequency(as5); 1237 | delay_ms(500); 1238 | 1239 | stop01(); 1240 | delay_ms(500); 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | counter=0; 1248 | goto skip2; 1249 | 1250 | while(counter!=2) 1251 | { 1252 | stop01(); 1253 | stop02(); 1254 | stop03(); 1255 | stop04(); 1256 | stop09(); 1257 | 1258 | wave11_volume(255); 1259 | wave11_frequency(d5); 1260 | delay_ms(120); 1261 | 1262 | wave11_frequency(f5); 1263 | delay_ms(120); 1264 | 1265 | wave11_frequency(as5); 1266 | delay_ms(120); 1267 | 1268 | wave11_frequency(f5); 1269 | delay_ms(120); 1270 | 1271 | wave11_frequency(c5); 1272 | delay_ms(120); 1273 | 1274 | wave11_frequency(e5); 1275 | delay_ms(120); 1276 | 1277 | wave11_frequency(a5); 1278 | delay_ms(120); 1279 | 1280 | wave11_frequency(e5); 1281 | delay_ms(120); 1282 | 1283 | wave11_frequency(as4); 1284 | delay_ms(120); 1285 | 1286 | wave11_frequency(d5); 1287 | delay_ms(120); 1288 | 1289 | wave11_frequency(g5); 1290 | delay_ms(120); 1291 | 1292 | wave11_frequency(d5); 1293 | delay_ms(120); 1294 | 1295 | wave11_frequency(a4); 1296 | delay_ms(120); 1297 | 1298 | wave11_frequency(cs5); 1299 | delay_ms(120); 1300 | 1301 | wave11_frequency(e5); 1302 | delay_ms(120); 1303 | 1304 | wave11_frequency(a5); 1305 | delay_ms(150); 1306 | stop11(); 1307 | 1308 | skip2: 1309 | wave09_volume(103); 1310 | wave01_volume(18); 1311 | wave09_frequency(d2); 1312 | wave01_frequency(d5); 1313 | delay_ms(270); 1314 | 1315 | wave02_volume(18); 1316 | wave03_volume(18); 1317 | wave02_frequency(f5); 1318 | wave03_frequency(as5); 1319 | delay_ms(300); 1320 | 1321 | stop02(); 1322 | stop03(); 1323 | wave09_frequency(c2); 1324 | wave01_frequency(a4); 1325 | delay_ms(315); 1326 | 1327 | wave02_volume(18); 1328 | wave03_volume(18); 1329 | wave02_frequency(e5); 1330 | wave03_frequency(a5); 1331 | delay_ms(340); 1332 | 1333 | stop02(); 1334 | stop03(); 1335 | wave09_frequency(as1); 1336 | wave01_frequency(as4); 1337 | delay_ms(350); 1338 | 1339 | wave02_volume(18); 1340 | wave03_volume(18); 1341 | wave02_frequency(d5); 1342 | wave03_frequency(g5); 1343 | delay_ms(400); 1344 | 1345 | wave04_volume(18); 1346 | wave09_frequency(a1); 1347 | wave01_frequency(e4); 1348 | wave02_frequency(cs5); 1349 | wave03_frequency(e5); 1350 | wave04_frequency(a5); 1351 | delay_ms(1000); 1352 | 1353 | counter=counter+1; 1354 | } 1355 | 1356 | wave09_frequency(gs1); 1357 | wave01_frequency(h4); 1358 | wave02_frequency(f4); 1359 | wave03_frequency(d4); 1360 | wave04_frequency(h3); 1361 | delay_ms(1000); 1362 | 1363 | wave09_frequency(g1); 1364 | wave01_frequency(cs5); 1365 | wave02_frequency(a4); 1366 | wave03_frequency(e4); 1367 | wave04_frequency(a3); 1368 | delay_ms(1500); 1369 | 1370 | stop02(); 1371 | stop03(); 1372 | stop04(); 1373 | stop09(); 1374 | wave01_frequency(h4); 1375 | counter=18; 1376 | while(counter<75) 1377 | { 1378 | counter=counter+1; 1379 | wave01_volume(counter); 1380 | delay_ms(1); 1381 | } 1382 | delay_ms(400); 1383 | 1384 | wave01_frequency(a4); 1385 | delay_ms(300); 1386 | 1387 | wave01_frequency(cs5); 1388 | delay_ms(200); 1389 | 1390 | wave01_frequency(e5); 1391 | delay_ms(200); 1392 | 1393 | wave01_frequency(g5); 1394 | delay_ms(300); 1395 | 1396 | wave01_frequency(as5); 1397 | delay_ms(1000); 1398 | 1399 | wave01_frequency(a5); 1400 | delay_ms(300); 1401 | 1402 | wave01_frequency(g5); 1403 | delay_ms(200); 1404 | 1405 | wave01_frequency(f5); 1406 | delay_ms(150); 1407 | 1408 | wave01_frequency(e5); 1409 | delay_ms(130); 1410 | 1411 | wave01_frequency(f5); 1412 | delay_ms(120); 1413 | 1414 | wave01_frequency(e5); 1415 | delay_ms(110); 1416 | 1417 | wave01_frequency(d5); 1418 | delay_ms(110); 1419 | 1420 | wave01_frequency(cs5); 1421 | delay_ms(110); 1422 | 1423 | wave01_frequency(d5); 1424 | delay_ms(110); 1425 | 1426 | wave01_frequency(c5); 1427 | delay_ms(110); 1428 | 1429 | wave01_frequency(as4); 1430 | delay_ms(110); 1431 | 1432 | wave01_frequency(a4); 1433 | delay_ms(110); 1434 | 1435 | wave01_frequency(g4); 1436 | delay_ms(110); 1437 | 1438 | wave01_frequency(f4); 1439 | delay_ms(120); 1440 | 1441 | wave01_frequency(e4); 1442 | delay_ms(130); 1443 | 1444 | wave01_frequency(d4); 1445 | delay_ms(150); 1446 | 1447 | 1448 | counter=75; 1449 | while(counter>14) 1450 | { 1451 | counter=counter-1; 1452 | wave01_volume(counter); 1453 | delay_ms(1); 1454 | } 1455 | wave09_volume(75); 1456 | wave02_volume(14); 1457 | wave03_volume(14); 1458 | wave04_volume(14); 1459 | wave05_volume(14); 1460 | wave06_volume(14); 1461 | wave09_frequency(g2); 1462 | wave01_frequency(cs5); 1463 | wave02_frequency(e4); 1464 | wave03_frequency(cs4); 1465 | wave04_frequency(g4); 1466 | wave05_frequency(as4); 1467 | wave06_frequency(e5); 1468 | delay_ms(1500); 1469 | 1470 | stop09(); 1471 | stop03(); 1472 | stop04(); 1473 | stop05(); 1474 | stop06(); 1475 | counter=14; 1476 | while(counter<60) 1477 | { 1478 | counter=counter+1; 1479 | wave01_volume(counter); 1480 | wave02_volume(counter); 1481 | delay_ms(1); 1482 | } 1483 | delay_ms(500); 1484 | 1485 | counter=0; 1486 | while(counter!=4) 1487 | { 1488 | wave01_frequency(cs5); 1489 | wave02_frequency(e4); 1490 | delay_ms(110); 1491 | 1492 | wave01_frequency(e5); 1493 | wave02_frequency(g4); 1494 | delay_ms(110); 1495 | 1496 | wave01_frequency(cs5); 1497 | wave02_frequency(e4); 1498 | delay_ms(110); 1499 | 1500 | wave01_frequency(as4); 1501 | wave02_frequency(cs4); 1502 | delay_ms(110); 1503 | 1504 | wave01_frequency(cs5); 1505 | wave02_frequency(e4); 1506 | delay_ms(110); 1507 | 1508 | wave01_frequency(as4); 1509 | wave02_frequency(cs4); 1510 | delay_ms(110); 1511 | counter=counter+1; 1512 | } 1513 | 1514 | counter=0; 1515 | while(counter!=4) 1516 | { 1517 | wave01_frequency(g4); 1518 | wave02_frequency(as3); 1519 | delay_ms(110); 1520 | 1521 | wave01_frequency(as4); 1522 | wave02_frequency(cs4); 1523 | delay_ms(110); 1524 | 1525 | wave01_frequency(g4); 1526 | wave02_frequency(as3); 1527 | delay_ms(110); 1528 | 1529 | wave01_frequency(e4); 1530 | wave02_frequency(g3); 1531 | delay_ms(110); 1532 | 1533 | wave01_frequency(g4); 1534 | wave02_frequency(as3); 1535 | delay_ms(110); 1536 | 1537 | wave01_frequency(e4); 1538 | wave02_frequency(g3); 1539 | delay_ms(110); 1540 | counter=counter+1; 1541 | } 1542 | 1543 | counter=0; 1544 | while(counter!=4) 1545 | { 1546 | wave01_frequency(cs4); 1547 | wave02_frequency(e3); 1548 | delay_ms(110); 1549 | 1550 | wave01_frequency(e4); 1551 | wave02_frequency(g3); 1552 | delay_ms(110); 1553 | 1554 | wave01_frequency(cs4); 1555 | wave02_frequency(e3); 1556 | delay_ms(110); 1557 | 1558 | wave01_frequency(as3); 1559 | wave02_frequency(cs3); 1560 | delay_ms(110); 1561 | 1562 | wave01_frequency(cs4); 1563 | wave02_frequency(e3); 1564 | delay_ms(110); 1565 | 1566 | wave01_frequency(as3); 1567 | wave02_frequency(cs3); 1568 | delay_ms(110); 1569 | counter=counter+1; 1570 | } 1571 | 1572 | counter=0; 1573 | while(counter!=4) 1574 | { 1575 | wave01_frequency(cs4); 1576 | wave02_frequency(e3); 1577 | delay_ms(110); 1578 | 1579 | wave01_frequency(e4); 1580 | wave02_frequency(g3); 1581 | delay_ms(110); 1582 | 1583 | wave01_frequency(cs4); 1584 | wave02_frequency(e3); 1585 | delay_ms(110); 1586 | 1587 | wave01_frequency(e4); 1588 | wave02_frequency(g3); 1589 | delay_ms(110); 1590 | 1591 | wave01_frequency(g4); 1592 | wave02_frequency(as3); 1593 | delay_ms(110); 1594 | 1595 | wave01_frequency(e4); 1596 | wave02_frequency(g3); 1597 | delay_ms(110); 1598 | counter=counter+1; 1599 | } 1600 | 1601 | counter=0; 1602 | while(counter!=3) 1603 | { 1604 | wave01_frequency(g4); 1605 | wave02_frequency(e3); 1606 | delay_ms(110); 1607 | 1608 | wave01_frequency(as4); 1609 | wave02_frequency(g3); 1610 | delay_ms(110); 1611 | counter=counter+1; 1612 | } 1613 | 1614 | counter=0; 1615 | while(counter!=3) 1616 | { 1617 | wave01_frequency(g4); 1618 | wave02_frequency(as3); 1619 | delay_ms(110); 1620 | 1621 | wave01_frequency(as4); 1622 | wave02_frequency(cs4); 1623 | delay_ms(110); 1624 | counter=counter+1; 1625 | } 1626 | 1627 | wave01_frequency(cs5); 1628 | wave02_frequency(e4); 1629 | delay_ms(110); 1630 | 1631 | wave01_frequency(as4); 1632 | wave02_frequency(cs4); 1633 | delay_ms(110); 1634 | 1635 | counter=0; 1636 | while(counter!=4) 1637 | { 1638 | wave01_frequency(cs5); 1639 | wave02_frequency(e4); 1640 | delay_ms(110); 1641 | 1642 | wave01_frequency(e5); 1643 | wave02_frequency(cs4); 1644 | delay_ms(110); 1645 | counter=counter+1; 1646 | } 1647 | 1648 | delay_ms(200); 1649 | counter=60; 1650 | while(counter>12) 1651 | { 1652 | counter=counter-1; 1653 | wave01_volume(counter); 1654 | wave02_volume(counter); 1655 | delay_ms(1); 1656 | } 1657 | 1658 | wave09_volume(73); 1659 | wave03_volume(12); 1660 | wave04_volume(12); 1661 | wave05_volume(12); 1662 | wave06_volume(12); 1663 | wave07_volume(12); 1664 | wave09_frequency(g2); 1665 | wave01_frequency(a3); 1666 | wave02_frequency(cs4); 1667 | wave03_frequency(e4); 1668 | wave04_frequency(a4); 1669 | wave05_frequency(cs5); 1670 | wave06_frequency(e5); 1671 | wave07_frequency(a5); 1672 | delay_ms(1000); 1673 | 1674 | wave09_frequency(f2); 1675 | wave02_frequency(d4); 1676 | wave03_frequency(f4); 1677 | wave05_frequency(d5); 1678 | wave06_frequency(f5); 1679 | delay_ms(1200); 1680 | 1681 | stop06(); 1682 | stop07(); 1683 | wave09_volume(95); 1684 | wave01_volume(15); 1685 | wave02_volume(15); 1686 | wave03_volume(15); 1687 | wave04_volume(15); 1688 | wave05_volume(15); 1689 | wave09_frequency(as2); 1690 | wave01_frequency(g4); 1691 | wave03_frequency(as4); 1692 | wave04_frequency(g5); 1693 | delay_ms(1500); 1694 | 1695 | stop01(); 1696 | stop02(); 1697 | stop03(); 1698 | stop04(); 1699 | stop05(); 1700 | counter=95; 1701 | while(counter!=255) 1702 | { 1703 | counter=counter+1; 1704 | wave09_volume(counter); 1705 | delay_ms(1); 1706 | } 1707 | delay_ms(1000); 1708 | 1709 | wave09_frequency(a2); 1710 | delay_ms(600); 1711 | 1712 | wave09_frequency(g2); 1713 | delay_ms(400); 1714 | 1715 | counter=255; 1716 | while(counter!=75) 1717 | { 1718 | counter=counter-1; 1719 | wave09_volume(counter); 1720 | delay_ms(1); 1721 | } 1722 | 1723 | wave01_volume(14); 1724 | wave02_volume(14); 1725 | wave03_volume(14); 1726 | wave04_volume(14); 1727 | wave05_volume(14); 1728 | wave06_volume(14); 1729 | wave09_frequency(a2); 1730 | wave01_frequency(cs4); 1731 | wave02_frequency(e4); 1732 | wave03_frequency(a4); 1733 | wave04_frequency(cs5); 1734 | wave05_frequency(e5); 1735 | wave06_frequency(g5); 1736 | delay_ms(1500); 1737 | 1738 | stop01(); 1739 | stop02(); 1740 | stop03(); 1741 | stop04(); 1742 | stop05(); 1743 | stop06(); 1744 | wave09_frequency(e2); 1745 | counter=74; 1746 | while(counter!=255) 1747 | { 1748 | counter=counter+1; 1749 | wave09_volume(counter); 1750 | delay_ms(1); 1751 | } 1752 | delay_ms(400); 1753 | 1754 | wave09_frequency(f2); 1755 | delay_ms(400); 1756 | 1757 | wave09_frequency(d2); 1758 | delay_ms(300); 1759 | 1760 | wave09_frequency(e2); 1761 | delay_ms(250); 1762 | 1763 | wave09_frequency(cs2); 1764 | delay_ms(200); 1765 | 1766 | wave09_frequency(d2); 1767 | delay_ms(200); 1768 | 1769 | wave09_frequency(h1); 1770 | delay_ms(200); 1771 | 1772 | wave09_frequency(cs2); 1773 | delay_ms(200); 1774 | 1775 | wave09_frequency(a1); 1776 | delay_ms(250); 1777 | 1778 | wave09_frequency(as1); 1779 | delay_ms(300); 1780 | 1781 | wave09_frequency(gs1); 1782 | delay_ms(400); 1783 | 1784 | wave09_frequency(a1); 1785 | delay_ms(400); 1786 | 1787 | counter=255; 1788 | while(counter!=103) 1789 | { 1790 | counter=counter-1; 1791 | wave09_volume(counter); 1792 | delay_ms(1); 1793 | } 1794 | 1795 | wave01_volume(18); 1796 | wave02_volume(18); 1797 | wave03_volume(18); 1798 | wave04_volume(18); 1799 | wave09_frequency(g2); 1800 | wave01_frequency(a3); 1801 | wave02_frequency(e4); 1802 | wave03_frequency(cs5); 1803 | wave04_frequency(a4); 1804 | delay_ms(500); 1805 | 1806 | 1807 | wave09_volume(95); 1808 | wave01_volume(15); 1809 | wave02_volume(15); 1810 | wave03_volume(15); 1811 | wave04_volume(15); 1812 | wave05_volume(15); 1813 | wave09_frequency(f2); 1814 | wave02_frequency(d4); 1815 | wave03_frequency(f4); 1816 | wave05_frequency(d5); 1817 | delay_ms(1000); 1818 | 1819 | stop04(); 1820 | stop05(); 1821 | wave09_volume(123); 1822 | wave01_volume(21); 1823 | wave02_volume(21); 1824 | wave03_volume(21); 1825 | wave09_frequency(d2); 1826 | delay_ms(1500); 1827 | 1828 | wave09_frequency(a1); 1829 | wave03_frequency(e4); 1830 | delay_ms(1500); 1831 | 1832 | wave02_frequency(cs4); 1833 | delay_ms(1000); 1834 | 1835 | wave01_frequency(g3); 1836 | delay_ms(1000); 1837 | 1838 | wave09_volume(103); 1839 | wave01_volume(27); 1840 | wave02_volume(15); 1841 | wave03_volume(15); 1842 | wave04_volume(15); 1843 | wave09_frequency(d1); 1844 | wave02_frequency(d3); 1845 | wave03_frequency(a3); 1846 | wave04_frequency(d4); 1847 | delay_ms(2000); 1848 | 1849 | wave01_frequency(f3); 1850 | delay_ms(1000); 1851 | 1852 | wave01_frequency(e3); 1853 | delay_ms(1500); 1854 | 1855 | wave01_frequency(f3); 1856 | delay_ms(5000); 1857 | 1858 | stop01(); 1859 | stop02(); 1860 | stop03(); 1861 | stop04(); 1862 | stop09(); 1863 | delay_ms(5000); 1864 | end_secondProgram -------------------------------------------------------------------------------- /examples/tetris_A-theme/tetris_A-theme.ino: -------------------------------------------------------------------------------- 1 | //requirements: 2 | //3 voices 3 | //5kb +/- program memory 4 | 5 | 6 | 7 | #include 8 | 9 | #define DELAY delay_ms(200); 10 | 11 | 12 | byte counter; 13 | 14 | void setup() 15 | { 16 | synthSetup(); 17 | pinMode(13, OUTPUT); 18 | } 19 | 20 | void loop() 21 | { 22 | digitalWrite(13, HIGH); 23 | delay(1000); 24 | digitalWrite(13, LOW); 25 | delay(1000); 26 | } 27 | 28 | 29 | 30 | void stop01() 31 | { 32 | wave01_volume(0); 33 | wave01_frequency(0); 34 | wave01_phase(0); 35 | } 36 | 37 | void stop02() 38 | { 39 | wave02_volume(0); 40 | wave02_frequency(0); 41 | wave02_phase(0); 42 | } 43 | 44 | void stop03() 45 | { 46 | wave03_volume(0); 47 | wave03_frequency(0); 48 | wave03_phase(1<<14); 49 | } 50 | 51 | 52 | 53 | start_interrupt 54 | wave01(); 55 | squareWave(); 56 | wave02(); 57 | squareWave(); 58 | wave03(); 59 | triangleWave(); 60 | end_interrupt 61 | 62 | start_secondProgram 63 | counter=0; 64 | while(counter!=2) 65 | { 66 | wave01_volume(15); 67 | wave02_volume(15); 68 | wave03_volume(193); 69 | wave01_frequency(e5); 70 | wave02_frequency(b4); 71 | wave03_frequency(e2); 72 | DELAY 73 | wave03_frequency(e3); 74 | DELAY 75 | wave01_frequency(b4); 76 | wave02_frequency(gs4); 77 | wave03_frequency(e2); 78 | DELAY 79 | wave01_frequency(c5); 80 | wave02_frequency(a4); 81 | wave03_frequency(e3); 82 | DELAY 83 | 84 | wave01_frequency(d5); 85 | wave02_frequency(b4); 86 | wave03_frequency(e2); 87 | DELAY 88 | wave03_frequency(e3); 89 | DELAY 90 | wave01_frequency(c5); 91 | wave02_frequency(a4); 92 | wave03_frequency(e2); 93 | DELAY 94 | wave01_frequency(b4); 95 | wave02_frequency(gs4); 96 | wave03_frequency(e3); 97 | DELAY 98 | 99 | wave01_frequency(a4); 100 | wave02_frequency(e4); 101 | wave03_frequency(a2); 102 | DELAY 103 | wave03_frequency(a3); 104 | DELAY 105 | wave03_frequency(a2); 106 | DELAY 107 | wave01_frequency(c5); 108 | wave02_frequency(a4); 109 | wave03_frequency(a3); 110 | DELAY 111 | 112 | wave01_frequency(e5); 113 | wave02_frequency(c5); 114 | wave03_frequency(a2); 115 | DELAY 116 | wave03_frequency(a3); 117 | DELAY 118 | wave01_frequency(d5); 119 | wave02_frequency(b4); 120 | wave03_frequency(a2); 121 | DELAY 122 | wave01_frequency(c5); 123 | wave02_frequency(a4); 124 | wave03_frequency(a3); 125 | DELAY 126 | 127 | wave01_frequency(b4); 128 | wave02_frequency(gs4); 129 | wave03_frequency(gs2); 130 | DELAY 131 | wave03_frequency(gs3); 132 | DELAY 133 | wave03_frequency(gs2); 134 | DELAY 135 | wave01_frequency(c5); 136 | wave02_frequency(a4); 137 | wave03_frequency(gs3); 138 | DELAY 139 | 140 | wave01_frequency(d5); 141 | wave02_frequency(b4); 142 | wave03_frequency(e2); 143 | DELAY 144 | wave03_frequency(e3); 145 | DELAY 146 | wave01_frequency(e5); 147 | wave02_frequency(b4); 148 | wave03_frequency(e2); 149 | DELAY 150 | wave03_frequency(e3); 151 | DELAY 152 | 153 | wave01_frequency(c5); 154 | wave02_frequency(a4); 155 | wave03_frequency(a2); 156 | DELAY 157 | wave03_frequency(a3); 158 | DELAY 159 | wave01_frequency(a4); 160 | wave02_frequency(e4); 161 | wave03_frequency(a2); 162 | DELAY 163 | wave03_frequency(a3); 164 | DELAY 165 | 166 | wave03_frequency(a2); 167 | DELAY 168 | wave03_frequency(a3); 169 | DELAY 170 | stop01(); 171 | stop02(); 172 | wave03_frequency(b2); 173 | DELAY 174 | wave03_frequency(c3); 175 | DELAY 176 | 177 | wave01_volume(15); 178 | wave02_volume(15); 179 | wave01_frequency(d5); 180 | wave02_frequency(a4); 181 | wave03_frequency(d2); 182 | DELAY 183 | wave03_frequency(d3); 184 | DELAY 185 | wave03_frequency(d2); 186 | DELAY 187 | wave01_frequency(f5); 188 | wave02_frequency(d5); 189 | wave03_frequency(d3); 190 | DELAY 191 | 192 | wave01_frequency(a5); 193 | wave02_frequency(f5); 194 | wave03_frequency(d2); 195 | DELAY 196 | wave03_frequency(d3); 197 | DELAY 198 | wave01_frequency(g5); 199 | wave02_frequency(e5); 200 | wave03_frequency(d2); 201 | DELAY 202 | wave01_frequency(f5); 203 | wave02_frequency(d5); 204 | wave03_frequency(d3); 205 | DELAY 206 | 207 | wave01_frequency(e5); 208 | wave02_frequency(c5); 209 | wave03_frequency(a2); 210 | DELAY 211 | wave03_frequency(a3); 212 | DELAY 213 | wave03_frequency(a2); 214 | DELAY 215 | wave01_frequency(c5); 216 | wave02_frequency(a4); 217 | wave03_frequency(a3); 218 | DELAY 219 | 220 | wave01_frequency(e5); 221 | wave02_frequency(c5); 222 | wave03_frequency(a2); 223 | DELAY 224 | wave03_frequency(a3); 225 | DELAY 226 | wave01_frequency(d5); 227 | wave02_frequency(b4); 228 | wave03_frequency(a2); 229 | DELAY 230 | wave01_frequency(c5); 231 | wave02_frequency(a4); 232 | wave03_frequency(a3); 233 | DELAY 234 | 235 | wave01_frequency(b4); 236 | wave02_frequency(gs4); 237 | wave03_frequency(gs2); 238 | DELAY 239 | wave03_frequency(gs3); 240 | DELAY 241 | wave03_frequency(gs2); 242 | DELAY 243 | wave01_frequency(c5); 244 | wave02_frequency(a4); 245 | wave03_frequency(gs3); 246 | DELAY 247 | 248 | wave01_frequency(d5); 249 | wave02_frequency(b4); 250 | wave03_frequency(e2); 251 | DELAY 252 | wave03_frequency(e3); 253 | DELAY 254 | wave01_frequency(e5); 255 | wave02_frequency(b4); 256 | wave03_frequency(e2); 257 | DELAY 258 | wave03_frequency(e3); 259 | DELAY 260 | 261 | wave01_frequency(c5); 262 | wave02_frequency(a4); 263 | wave03_frequency(a2); 264 | DELAY 265 | wave03_frequency(a3); 266 | DELAY 267 | wave01_frequency(a4); 268 | wave02_frequency(e4); 269 | wave03_frequency(a2); 270 | DELAY 271 | wave03_frequency(a3); 272 | DELAY 273 | 274 | wave03_frequency(a2); 275 | DELAY 276 | DELAY 277 | stop01(); 278 | stop02(); 279 | stop03(); 280 | DELAY 281 | DELAY 282 | 283 | counter=counter+1; 284 | } 285 | 286 | counter=0; 287 | while(counter!=2) 288 | { 289 | wave01_volume(30); 290 | wave02_volume(30); 291 | wave03_volume(133); 292 | wave01_frequency(e4); 293 | wave02_frequency(c4); 294 | wave03_frequency(a4); 295 | DELAY 296 | wave03_frequency(e5); 297 | DELAY 298 | wave03_frequency(a4); 299 | DELAY 300 | wave03_frequency(e5); 301 | DELAY 302 | 303 | wave01_frequency(c4); 304 | wave02_frequency(a3); 305 | wave03_frequency(a4); 306 | DELAY 307 | wave03_frequency(e5); 308 | DELAY 309 | wave03_frequency(a4); 310 | DELAY 311 | wave03_frequency(e5); 312 | DELAY 313 | 314 | wave01_frequency(d4); 315 | wave02_frequency(b3); 316 | wave03_frequency(gs4); 317 | DELAY 318 | wave03_frequency(e5); 319 | DELAY 320 | wave03_frequency(gs4); 321 | DELAY 322 | wave03_frequency(e5); 323 | DELAY 324 | 325 | wave01_frequency(b3); 326 | wave02_frequency(gs3); 327 | wave03_frequency(gs4); 328 | DELAY 329 | wave03_frequency(e5); 330 | DELAY 331 | wave03_frequency(gs4); 332 | DELAY 333 | wave03_frequency(e5); 334 | DELAY 335 | 336 | if(counter==0) 337 | { 338 | wave01_frequency(c4); 339 | wave02_frequency(a3); 340 | wave03_frequency(a4); 341 | DELAY 342 | wave03_frequency(e5); 343 | DELAY 344 | wave03_frequency(a4); 345 | DELAY 346 | wave03_frequency(e5); 347 | DELAY 348 | 349 | wave01_frequency(a3); 350 | wave02_frequency(e3); 351 | wave03_frequency(a4); 352 | DELAY 353 | wave03_frequency(e5); 354 | DELAY 355 | wave03_frequency(a4); 356 | DELAY 357 | wave03_frequency(e5); 358 | DELAY 359 | 360 | wave01_frequency(gs3); 361 | wave02_frequency(e3); 362 | wave03_frequency(gs4); 363 | DELAY 364 | wave03_frequency(e5); 365 | DELAY 366 | wave03_frequency(gs4); 367 | DELAY 368 | wave03_frequency(e5); 369 | DELAY 370 | 371 | wave01_frequency(b3); 372 | wave02_frequency(gs3); 373 | wave03_frequency(gs4); 374 | DELAY 375 | wave03_frequency(e5); 376 | DELAY 377 | wave03_frequency(gs4); 378 | DELAY 379 | wave03_frequency(e5); 380 | DELAY 381 | } 382 | counter=counter+1; 383 | } 384 | 385 | 386 | wave01_frequency(c4); 387 | wave02_frequency(a3); 388 | wave03_frequency(a4); 389 | DELAY 390 | wave03_frequency(e5); 391 | DELAY 392 | wave01_frequency(e4); 393 | wave02_frequency(c4); 394 | wave03_frequency(a4); 395 | DELAY 396 | wave03_frequency(e5); 397 | DELAY 398 | 399 | wave01_frequency(a4); 400 | wave02_frequency(e4); 401 | wave03_frequency(a4); 402 | DELAY 403 | wave03_frequency(e5); 404 | DELAY 405 | wave03_frequency(a4); 406 | DELAY 407 | wave03_frequency(e5); 408 | DELAY 409 | 410 | wave01_frequency(gs4); 411 | wave02_frequency(e4); 412 | wave03_frequency(gs4); 413 | DELAY 414 | wave03_frequency(e5); 415 | DELAY 416 | wave03_frequency(gs4); 417 | DELAY 418 | wave03_frequency(e5); 419 | DELAY 420 | 421 | stop01(); 422 | stop02(); 423 | stop03(); 424 | DELAY 425 | DELAY 426 | DELAY 427 | DELAY 428 | end_secondProgram 429 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For asmsynth 3 | ####################################### 4 | 5 | 6 | 7 | 8 | 9 | synthSetup KEYWORD1 10 | asmsynth KEYWORD1 11 | 12 | 13 | 14 | 15 | 16 | keyboard KEYWORD2 17 | hz KEYWORD2 18 | delay_ms KEYWORD2 19 | delay_ci KEYWORD2 20 | get_ms KEYWORD2 21 | get_ci KEYWORD2 22 | pause KEYWORD2 23 | play KEYWORD2 24 | reset KEYWORD2 25 | stop KEYWORD2 26 | volume KEYWORD2 27 | ADCchannel KEYWORD2 28 | motorA KEYWORD2 29 | motorB KEYWORD2 30 | 31 | squareWave KEYWORD2 32 | sawWave KEYWORD2 33 | triangleWave KEYWORD2 34 | sinWave KEYWORD2 35 | noiseWave KEYWORD2 36 | 37 | wave01 KEYWORD2 38 | wave02 KEYWORD2 39 | wave03 KEYWORD2 40 | wave04 KEYWORD2 41 | wave05 KEYWORD2 42 | wave06 KEYWORD2 43 | wave07 KEYWORD2 44 | wave08 KEYWORD2 45 | wave09 KEYWORD2 46 | wave10 KEYWORD2 47 | wave11 KEYWORD2 48 | wave12 KEYWORD2 49 | wave13 KEYWORD2 50 | wave14 KEYWORD2 51 | wave15 KEYWORD2 52 | wave16 KEYWORD2 53 | wave17 KEYWORD2 54 | wave18 KEYWORD2 55 | wave19 KEYWORD2 56 | wave20 KEYWORD2 57 | wave21 KEYWORD2 58 | wave22 KEYWORD2 59 | wave23 KEYWORD2 60 | wave24 KEYWORD2 61 | wave25 KEYWORD2 62 | wave26 KEYWORD2 63 | wave27 KEYWORD2 64 | wave28 KEYWORD2 65 | wave29 KEYWORD2 66 | wave30 KEYWORD2 67 | wave31 KEYWORD2 68 | wave32 KEYWORD2 69 | 70 | wave01_volume KEYWORD2 71 | wave02_volume KEYWORD2 72 | wave03_volume KEYWORD2 73 | wave04_volume KEYWORD2 74 | wave05_volume KEYWORD2 75 | wave06_volume KEYWORD2 76 | wave07_volume KEYWORD2 77 | wave08_volume KEYWORD2 78 | wave09_volume KEYWORD2 79 | wave10_volume KEYWORD2 80 | wave11_volume KEYWORD2 81 | wave12_volume KEYWORD2 82 | wave13_volume KEYWORD2 83 | wave14_volume KEYWORD2 84 | wave15_volume KEYWORD2 85 | wave16_volume KEYWORD2 86 | wave17_volume KEYWORD2 87 | wave18_volume KEYWORD2 88 | wave19_volume KEYWORD2 89 | wave20_volume KEYWORD2 90 | wave21_volume KEYWORD2 91 | wave22_volume KEYWORD2 92 | wave23_volume KEYWORD2 93 | wave24_volume KEYWORD2 94 | wave25_volume KEYWORD2 95 | wave26_volume KEYWORD2 96 | wave27_volume KEYWORD2 97 | wave28_volume KEYWORD2 98 | wave29_volume KEYWORD2 99 | wave30_volume KEYWORD2 100 | wave31_volume KEYWORD2 101 | wave32_volume KEYWORD2 102 | 103 | wave01_phase KEYWORD2 104 | wave02_phase KEYWORD2 105 | wave03_phase KEYWORD2 106 | wave04_phase KEYWORD2 107 | wave05_phase KEYWORD2 108 | wave06_phase KEYWORD2 109 | wave07_phase KEYWORD2 110 | wave08_phase KEYWORD2 111 | wave09_phase KEYWORD2 112 | wave10_phase KEYWORD2 113 | wave11_phase KEYWORD2 114 | wave12_phase KEYWORD2 115 | wave13_phase KEYWORD2 116 | wave14_phase KEYWORD2 117 | wave15_phase KEYWORD2 118 | wave16_phase KEYWORD2 119 | wave17_phase KEYWORD2 120 | wave18_phase KEYWORD2 121 | wave19_phase KEYWORD2 122 | wave20_phase KEYWORD2 123 | wave21_phase KEYWORD2 124 | wave22_phase KEYWORD2 125 | wave23_phase KEYWORD2 126 | wave24_phase KEYWORD2 127 | wave25_phase KEYWORD2 128 | wave26_phase KEYWORD2 129 | wave27_phase KEYWORD2 130 | wave28_phase KEYWORD2 131 | wave29_phase KEYWORD2 132 | wave30_phase KEYWORD2 133 | wave31_phase KEYWORD2 134 | wave32_phase KEYWORD2 135 | 136 | wave01_frequency KEYWORD2 137 | wave02_frequency KEYWORD2 138 | wave03_frequency KEYWORD2 139 | wave04_frequency KEYWORD2 140 | wave05_frequency KEYWORD2 141 | wave06_frequency KEYWORD2 142 | wave07_frequency KEYWORD2 143 | wave08_frequency KEYWORD2 144 | wave09_frequency KEYWORD2 145 | wave10_frequency KEYWORD2 146 | wave11_frequency KEYWORD2 147 | wave12_frequency KEYWORD2 148 | wave13_frequency KEYWORD2 149 | wave14_frequency KEYWORD2 150 | wave15_frequency KEYWORD2 151 | wave16_frequency KEYWORD2 152 | wave17_frequency KEYWORD2 153 | wave18_frequency KEYWORD2 154 | wave19_frequency KEYWORD2 155 | wave20_frequency KEYWORD2 156 | wave21_frequency KEYWORD2 157 | wave22_frequency KEYWORD2 158 | wave23_frequency KEYWORD2 159 | wave24_frequency KEYWORD2 160 | wave25_frequency KEYWORD2 161 | wave26_frequency KEYWORD2 162 | wave27_frequency KEYWORD2 163 | wave28_frequency KEYWORD2 164 | wave29_frequency KEYWORD2 165 | wave30_frequency KEYWORD2 166 | wave31_frequency KEYWORD2 167 | wave32_frequency KEYWORD2 168 | 169 | 170 | 171 | 172 | 173 | sPin RESERVED_WORD 174 | sTime RESERVED_WORD 175 | sDelay RESERVED_WORD 176 | sVolume RESERVED_WORD 177 | sMotorA RESERVED_WORD 178 | sMotorB RESERVED_WORD 179 | 180 | w01 RESERVED_WORD 181 | w02 RESERVED_WORD 182 | w03 RESERVED_WORD 183 | w04 RESERVED_WORD 184 | w05 RESERVED_WORD 185 | w06 RESERVED_WORD 186 | w07 RESERVED_WORD 187 | w08 RESERVED_WORD 188 | w09 RESERVED_WORD 189 | w10 RESERVED_WORD 190 | w11 RESERVED_WORD 191 | w12 RESERVED_WORD 192 | w13 RESERVED_WORD 193 | w14 RESERVED_WORD 194 | w15 RESERVED_WORD 195 | w16 RESERVED_WORD 196 | w17 RESERVED_WORD 197 | w18 RESERVED_WORD 198 | w19 RESERVED_WORD 199 | w20 RESERVED_WORD 200 | w21 RESERVED_WORD 201 | w22 RESERVED_WORD 202 | w23 RESERVED_WORD 203 | w24 RESERVED_WORD 204 | w25 RESERVED_WORD 205 | w26 RESERVED_WORD 206 | w27 RESERVED_WORD 207 | w28 RESERVED_WORD 208 | w29 RESERVED_WORD 209 | w30 RESERVED_WORD 210 | w31 RESERVED_WORD 211 | w32 RESERVED_WORD 212 | 213 | 214 | c0 LITERAL1 215 | cs0 LITERAL1 216 | d0 LITERAL1 217 | ds0 LITERAL1 218 | e0 LITERAL1 219 | f0 LITERAL1 220 | fs0 LITERAL1 221 | g0 LITERAL1 222 | gs0 LITERAL1 223 | a0 LITERAL1 224 | as0 LITERAL1 225 | b0 LITERAL1 226 | h0 LITERAL1 227 | 228 | c1 LITERAL1 229 | cs1 LITERAL1 230 | d1 LITERAL1 231 | ds1 LITERAL1 232 | e1 LITERAL1 233 | f1 LITERAL1 234 | fs1 LITERAL1 235 | g1 LITERAL1 236 | gs1 LITERAL1 237 | a1 LITERAL1 238 | as1 LITERAL1 239 | b1 LITERAL1 240 | h1 LITERAL1 241 | 242 | c2 LITERAL1 243 | cs2 LITERAL1 244 | d2 LITERAL1 245 | ds2 LITERAL1 246 | e2 LITERAL1 247 | f2 LITERAL1 248 | fs2 LITERAL1 249 | g2 LITERAL1 250 | gs2 LITERAL1 251 | a2 LITERAL1 252 | as2 LITERAL1 253 | b2 LITERAL1 254 | h2 LITERAL1 255 | 256 | c3 LITERAL1 257 | cs3 LITERAL1 258 | d3 LITERAL1 259 | ds3 LITERAL1 260 | e3 LITERAL1 261 | f3 LITERAL1 262 | fs3 LITERAL1 263 | g3 LITERAL1 264 | gs3 LITERAL1 265 | a3 LITERAL1 266 | as3 LITERAL1 267 | b3 LITERAL1 268 | h3 LITERAL1 269 | 270 | c4 LITERAL1 271 | cs4 LITERAL1 272 | d4 LITERAL1 273 | ds4 LITERAL1 274 | e4 LITERAL1 275 | f4 LITERAL1 276 | fs4 LITERAL1 277 | g4 LITERAL1 278 | gs4 LITERAL1 279 | a4 LITERAL1 280 | as4 LITERAL1 281 | b4 LITERAL1 282 | h4 LITERAL1 283 | 284 | c5 LITERAL1 285 | cs5 LITERAL1 286 | d5 LITERAL1 287 | ds5 LITERAL1 288 | e5 LITERAL1 289 | f5 LITERAL1 290 | fs5 LITERAL1 291 | g5 LITERAL1 292 | gs5 LITERAL1 293 | a5 LITERAL1 294 | as5 LITERAL1 295 | b5 LITERAL1 296 | h5 LITERAL1 297 | 298 | c6 LITERAL1 299 | cs6 LITERAL1 300 | d6 LITERAL1 301 | ds6 LITERAL1 302 | e6 LITERAL1 303 | f6 LITERAL1 304 | fs6 LITERAL1 305 | g6 LITERAL1 306 | gs6 LITERAL1 307 | a6 LITERAL1 308 | as6 LITERAL1 309 | b6 LITERAL1 310 | h6 LITERAL1 311 | 312 | c7 LITERAL1 313 | cs7 LITERAL1 314 | d7 LITERAL1 315 | ds7 LITERAL1 316 | e7 LITERAL1 317 | f7 LITERAL1 318 | fs7 LITERAL1 319 | g7 LITERAL1 320 | gs7 LITERAL1 321 | a7 LITERAL1 322 | as7 LITERAL1 323 | b7 LITERAL1 324 | h7 LITERAL1 325 | 326 | c8 LITERAL1 327 | cs8 LITERAL1 328 | d8 LITERAL1 329 | ds8 LITERAL1 330 | e8 LITERAL1 331 | f8 LITERAL1 332 | fs8 LITERAL1 333 | g8 LITERAL1 334 | gs8 LITERAL1 335 | a8 LITERAL1 336 | as8 LITERAL1 337 | b8 LITERAL1 338 | h8 LITERAL1 339 | 340 | 341 | 342 | 343 | 344 | start_interrupt KEYWORD1 PREPROCESSOR 345 | end_interrupt KEYWORD1 PREPROCESSOR 346 | 347 | start_secondProgram KEYWORD1 PREPROCESSOR 348 | end_secondProgram KEYWORD1 PREPROCESSOR -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=asmsynth 2 | version=0.1.0 3 | author=Pawel Sokol 4 | maintainer=Pawel Sokol 5 | sentence=Create your 8-bit music (up to 32 voices). 6 | paragraph=This is audio library and allows you to generate up to 32 voices at the same time. It also allows you to create background music by executing two programs asynchronously. In addition, the H bridge is supported, so you can use it as a speaker amplifier or control the motors. 7 | category=Other 8 | url=https://github.com/ezasm/asmsynth 9 | architectures=* 10 | includes=asmsynth.h 11 | -------------------------------------------------------------------------------- /src/asmsynth.S: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ezasm/asmsynth/20f70289c53cce63a063fa63b9c6385da021640d/src/asmsynth.S -------------------------------------------------------------------------------- /src/asmsynth.c: -------------------------------------------------------------------------------- 1 | #ifdef MusicSynthesizer_c 2 | 3 | //#include 4 | 5 | #ifndef disable_secondProgram 6 | //extern void delay_ci(unsigned long a); 7 | void delay_ms(float a) 8 | { 9 | a=a*F_CPU/256/1000; 10 | delay_ci(a); 11 | } 12 | 13 | //extern long get_ci(); 14 | float get_ms() 15 | { 16 | return get_ci()*1000*256/F_CPU; 17 | } 18 | #endif 19 | 20 | int hz(double hz) 21 | { 22 | //x=hz*a*b/1000000 23 | //a-wave sampling (number of samples per wave) 24 | //b-sound sampling (in microseconds) 25 | return hz*65536*SOUND_SAMPLING/1000000; 26 | } 27 | 28 | unsigned int keyboard(double key) 29 | { 30 | key=hz(TUNE*pow(TONE_INTERVAL, ((key-KEY_SHIFT)/NUMBER_OF_TONES))); 31 | return key; 32 | } 33 | 34 | unsigned int keyboard(double key, double cent) 35 | { 36 | key=keyboard(key+cent/100); 37 | return key; 38 | } 39 | 40 | void startinterrupt() 41 | { 42 | asm volatile 43 | ( 44 | "push r25\n" 45 | "in r25, 0x3F\n" 46 | "push r25\n" 47 | #if mode == 2 48 | "lds r25, (sPin)\n" 49 | "cpi r25, 255\n" 50 | "breq pominpiny\n" 51 | "sbrs r25, 0\n" 52 | C_Cpin1 53 | "sbrs r25, 1\n" 54 | C_Cpin2 55 | #if channel == 2 56 | "sbrs r25, 2\n" 57 | C_Cpin3 58 | "sbrs r25, 3\n" 59 | C_Cpin4 60 | #endif 61 | "sbrc r25, 0\n" 62 | C_Spin1 63 | "sbrc r25, 1\n" 64 | C_Spin2 65 | #if channel == 2 66 | "sbrc r25, 2\n" 67 | C_Spin3 68 | "sbrc r25, 3\n" 69 | C_Spin4 70 | #endif 71 | "ser r25\n" 72 | "sts (sPin), r25\n" 73 | "pominpiny:\n" 74 | #endif 75 | #ifndef disable_secondProgram 76 | "clt\n" 77 | "push r24\n" 78 | "lds r25, (sTime)\n" 79 | "lds r24, (sDelay)\n" 80 | "cp r24, r25\n" 81 | "brne pominprogram\n" 82 | "lds r25, (sTime+1)\n" 83 | "lds r24, (sDelay+1)\n" 84 | "cp r24, r25\n" 85 | "brne pominprogram\n" 86 | "lds r25, (sTime+2)\n" 87 | "lds r24, (sDelay+2)\n" 88 | "cp r24, r25\n" 89 | "brne pominprogram\n" 90 | "lds r25, (sTime+3)\n" 91 | "lds r24, (sDelay+3)\n" 92 | "cp r24, r25\n" 93 | "brne pominprogram\n" 94 | "set\n" 95 | "pominprogram:\n" 96 | #endif 97 | "lds r25, (sTime)\n" 98 | "inc r25\n" 99 | "sts (sTime), r25\n" 100 | #ifndef disable_secondProgram 101 | "brne przerwanie\n" 102 | "lds r24, (sTime+1)\n" 103 | "inc r24\n" 104 | "sts (sTime+1), r24\n" 105 | "brne przerwanie\n" 106 | "lds r24, (sTime+2)\n" 107 | "inc r24\n" 108 | "sts (sTime+2), r24\n" 109 | "brne przerwanie\n" 110 | "lds r24, (sTime+3)\n" 111 | "inc r24\n" 112 | "sts (sTime+3), r24\n" 113 | "przerwanie:\n" 114 | #endif 115 | #if INTERRUPT_COUNTER == 4 116 | "andi r25, 0x03\n" 117 | "cpi r25, 3\n" 118 | "breq dzw\n" 119 | #endif 120 | #if INTERRUPT_COUNTER == 2 121 | "sbrs r25, 0\n" 122 | #endif 123 | "rjmp pomindzw\n" 124 | "dzw:\n" 125 | "sei\n" 126 | #ifdef disable_secondProgram 127 | "push r24\n" 128 | #endif 129 | "push r23\n" 130 | "push r22\n" 131 | "push r21\n" 132 | "push r20\n" 133 | "push r1\n" 134 | "push r0\n" 135 | "clr r20\n" 136 | ); 137 | } 138 | 139 | void endinterrupt() 140 | { 141 | asm volatile 142 | ( 143 | #ifndef disable_volume 144 | "lds r21, (sVolume)\n" 145 | "mulsu r20, r21\n" 146 | "mov r20, r1\n" 147 | #endif 148 | #ifdef enable_ADC 149 | "lds r21, 0x79\n" 150 | "mulsu r20, r21\n" 151 | "mov r20, r1\n" 152 | #endif 153 | #if channel == 2 154 | "mov r21, r20\n" 155 | #endif 156 | #ifdef enable_motor 157 | "lds r22, (sMotorA)\n" 158 | "mov r23, r22\n" 159 | "sbrs r22, 7\n" 160 | "com r22\n" 161 | "lsl r22\n" 162 | "mulsu r20, r22\n" 163 | "mov r20, r1\n" 164 | "add r20, r23\n" 165 | #if channel == 2 166 | "lds r22, (sMotorB)\n" 167 | "mov r23, r22\n" 168 | "sbrs r22, 7\n" 169 | "com r22\n" 170 | "lsl r22\n" 171 | "mulsu r21, r22\n" 172 | "mov r21, r1\n" 173 | "add r21, r23\n" 174 | #endif 175 | #endif 176 | "cli\n" 177 | #if mode == 1 178 | "subi r20, 128\n" 179 | C_PWM1_20 180 | #if channel == 2 181 | "subi r21, 128\n" 182 | C_PWM2_21 183 | #endif 184 | #endif 185 | #if mode == 2 186 | "sbrs r20, 7\n" 187 | "rjmp plus1\n" 188 | "com r20\n" 189 | "lsl r20\n" 190 | C_PWM1_20 191 | "ldi r22, 2\n" 192 | #if channel == 1 193 | "sts (sPin), r22\n" 194 | "rjmp stos\n" 195 | #endif 196 | #if channel == 2 197 | "rjmp channel2\n" 198 | #endif 199 | "plus1:\n" 200 | "cpi r20, 0\n" 201 | "breq zero1\n" 202 | "lsl r20\n" 203 | C_PWM1_20 204 | "ldi r22, 1\n" 205 | #if channel == 1 206 | "sts (sPin), r22\n" 207 | "rjmp stos\n" 208 | #endif 209 | #if channel == 2 210 | "rjmp channel2\n" 211 | #endif 212 | "zero1:\n" 213 | C_PWM1_20 214 | #if channel == 1 215 | "sts (sPin), r20\n" 216 | #endif 217 | #if channel == 2 218 | "clr r22\n" 219 | "channel2:\n" 220 | "sbrs r21, 7\n" 221 | "rjmp plus2\n" 222 | "com r21\n" 223 | "lsl r21\n" 224 | C_PWM2_21 225 | "ori r22, 8\n" 226 | "sts (sPin), r22\n" 227 | "rjmp stos\n" 228 | "plus2:\n" 229 | "cpi r21, 0\n" 230 | "breq zero2\n" 231 | "lsl r21\n" 232 | C_PWM2_21 233 | "ori r22, 4\n" 234 | "sts (sPin), r22\n" 235 | "rjmp stos\n" 236 | "zero2:\n" 237 | C_PWM2_21 238 | "sts (sPin), r22\n" 239 | #endif 240 | #endif 241 | #if mode == 3 242 | "sbrs r20, 7\n" 243 | "rjmp plus1\n" 244 | "com r20\n" 245 | "lsl r20\n" 246 | C_PWM2_20 247 | "clr r20\n" 248 | C_PWM1_20 249 | #if channel == 1 250 | "rjmp stos\n" 251 | #endif 252 | #if channel == 2 253 | "rjmp channel2\n" 254 | #endif 255 | "plus1:\n" 256 | "lsl r21\n" 257 | C_PWM1_20 258 | "clr r20\n" 259 | C_PWM2_20 260 | #if channel == 2 261 | "channel2:\n" 262 | "sbrs r21, 7\n" 263 | "rjmp plus2\n" 264 | "com r21\n" 265 | "lsl r21\n" 266 | C_PWM4_21 267 | "clr r21\n" 268 | C_PWM3_21 269 | "rjmp stos\n" 270 | "plus2:\n" 271 | "lsl r21\n" 272 | C_PWM3_21 273 | "clr r21\n" 274 | C_PWM4_21 275 | #endif 276 | #endif 277 | "stos:\n" 278 | "pop r0\n" 279 | "pop r1\n" 280 | "pop r20\n" 281 | "pop r21\n" 282 | "pop r22\n" 283 | "pop r23\n" 284 | #ifdef disable_secondProgram 285 | "pop r24\n" 286 | #endif 287 | "pomindzw:\n" 288 | #ifndef disable_secondProgram 289 | "brtc powrot\n" 290 | "sei\n" 291 | "push r23\n" 292 | "push r22\n" 293 | "push r21\n" 294 | #ifndef enable_quickProgramChange 295 | "push r31\n" 296 | "push r30\n" 297 | "push r29\n" 298 | "push r28\n" 299 | "push r27\n" 300 | "push r26\n" 301 | "push r20\n" 302 | "push r19\n" 303 | "push r18\n" 304 | "push r17\n" 305 | "push r16\n" 306 | "push r15\n" 307 | "push r14\n" 308 | "push r13\n" 309 | "push r12\n" 310 | "push r11\n" 311 | "push r10\n" 312 | "push r9\n" 313 | "push r8\n" 314 | "push r7\n" 315 | "push r6\n" 316 | "push r5\n" 317 | "push r4\n" 318 | "push r3\n" 319 | "push r2\n" 320 | "push r1\n" 321 | "push r0\n" 322 | "clr r1\n" 323 | #endif 324 | "lds r25, (ProgramCounter)\n" 325 | "push r25\n" 326 | "lds r25, (ProgramCounter+1)\n" 327 | "push r25\n" 328 | "ret\n" 329 | "powrot:\n" 330 | "pop r24\n" 331 | #endif 332 | "pop r25\n" 333 | "out 0x3F, r25\n" 334 | "pop r25\n" 335 | "reti\n" 336 | ); 337 | } 338 | 339 | void squareWave() 340 | { 341 | asm volatile 342 | ( 343 | "sbrc r23, 7\n" 344 | "com r21\n" 345 | "add r20, r21\n" 346 | ); 347 | } 348 | 349 | void sawWave() 350 | { 351 | asm volatile 352 | ( 353 | "mulsu r23, r21\n" 354 | "add r20, r1\n" 355 | ); 356 | } 357 | 358 | void triangleWave() 359 | { 360 | 361 | asm volatile 362 | ( 363 | "sbrs r23, 7\n" 364 | "com r23\n" 365 | "lsl r23\n" 366 | "subi r23, 127\n" 367 | "mulsu r23, r21\n" 368 | "add r20, r1\n" 369 | ); 370 | } 371 | 372 | #if polyphony > 0 373 | void wave01() 374 | { 375 | asm volatile 376 | ( 377 | "lds r22, (w01)\n" 378 | "lds r23, (w01+1)\n" 379 | "lds r24, (w01+2)\n" 380 | "lds r25, (w01+3)\n" 381 | "lds r21, (w01+4)\n" 382 | "add r22, r24\n" 383 | "adc r23, r25\n" 384 | "sts (w01+1), r23\n" 385 | "sts (w01), r22\n" 386 | ); 387 | } 388 | #endif 389 | 390 | #if polyphony > 1 391 | void wave02() 392 | { 393 | asm volatile 394 | ( 395 | "lds r22, (w02)\n" 396 | "lds r23, (w02+1)\n" 397 | "lds r24, (w02+2)\n" 398 | "lds r25, (w02+3)\n" 399 | "lds r21, (w02+4)\n" 400 | "add r22, r24\n" 401 | "adc r23, r25\n" 402 | "sts (w02+1), r23\n" 403 | "sts (w02), r22\n" 404 | ); 405 | } 406 | #endif 407 | 408 | #if polyphony > 2 409 | void wave03() 410 | { 411 | asm volatile 412 | ( 413 | "lds r22, (w03)\n" 414 | "lds r23, (w03+1)\n" 415 | "lds r24, (w03+2)\n" 416 | "lds r25, (w03+3)\n" 417 | "lds r21, (w03+4)\n" 418 | "add r22, r24\n" 419 | "adc r23, r25\n" 420 | "sts (w03+1), r23\n" 421 | "sts (w03), r22\n" 422 | ); 423 | } 424 | #endif 425 | 426 | #if polyphony > 3 427 | void wave04() 428 | { 429 | asm volatile 430 | ( 431 | "lds r22, (w04)\n" 432 | "lds r23, (w04+1)\n" 433 | "lds r24, (w04+2)\n" 434 | "lds r25, (w04+3)\n" 435 | "lds r21, (w04+4)\n" 436 | "add r22, r24\n" 437 | "adc r23, r25\n" 438 | "sts (w04+1), r23\n" 439 | "sts (w04), r22\n" 440 | ); 441 | } 442 | #endif 443 | 444 | #if polyphony > 4 445 | void wave05() 446 | { 447 | asm volatile 448 | ( 449 | "lds r22, (w05)\n" 450 | "lds r23, (w05+1)\n" 451 | "lds r24, (w05+2)\n" 452 | "lds r25, (w05+3)\n" 453 | "lds r21, (w05+4)\n" 454 | "add r22, r24\n" 455 | "adc r23, r25\n" 456 | "sts (w05+1), r23\n" 457 | "sts (w05), r22\n" 458 | ); 459 | } 460 | #endif 461 | 462 | #if polyphony > 5 463 | void wave06() 464 | { 465 | asm volatile 466 | ( 467 | "lds r22, (w06)\n" 468 | "lds r23, (w06+1)\n" 469 | "lds r24, (w06+2)\n" 470 | "lds r25, (w06+3)\n" 471 | "lds r21, (w06+4)\n" 472 | "add r22, r24\n" 473 | "adc r23, r25\n" 474 | "sts (w06+1), r23\n" 475 | "sts (w06), r22\n" 476 | ); 477 | } 478 | #endif 479 | 480 | #if polyphony > 6 481 | void wave07() 482 | { 483 | asm volatile 484 | ( 485 | "lds r22, (w07)\n" 486 | "lds r23, (w07+1)\n" 487 | "lds r24, (w07+2)\n" 488 | "lds r25, (w07+3)\n" 489 | "lds r21, (w07+4)\n" 490 | "add r22, r24\n" 491 | "adc r23, r25\n" 492 | "sts (w07+1), r23\n" 493 | "sts (w07), r22\n" 494 | ); 495 | } 496 | #endif 497 | 498 | #if polyphony > 7 499 | void wave08() 500 | { 501 | asm volatile 502 | ( 503 | "lds r22, (w08)\n" 504 | "lds r23, (w08+1)\n" 505 | "lds r24, (w08+2)\n" 506 | "lds r25, (w08+3)\n" 507 | "lds r21, (w08+4)\n" 508 | "add r22, r24\n" 509 | "adc r23, r25\n" 510 | "sts (w08+1), r23\n" 511 | "sts (w08), r22\n" 512 | ); 513 | } 514 | #endif 515 | 516 | #if polyphony > 8 517 | void wave09() 518 | { 519 | asm volatile 520 | ( 521 | "lds r22, (w09)\n" 522 | "lds r23, (w09+1)\n" 523 | "lds r24, (w09+2)\n" 524 | "lds r25, (w09+3)\n" 525 | "lds r21, (w09+4)\n" 526 | "add r22, r24\n" 527 | "adc r23, r25\n" 528 | "sts (w09+1), r23\n" 529 | "sts (w09), r22\n" 530 | ); 531 | } 532 | #endif 533 | 534 | #if polyphony > 9 535 | void wave10() 536 | { 537 | asm volatile 538 | ( 539 | "lds r22, (w10)\n" 540 | "lds r23, (w10+1)\n" 541 | "lds r24, (w10+2)\n" 542 | "lds r25, (w10+3)\n" 543 | "lds r21, (w10+4)\n" 544 | "add r22, r24\n" 545 | "adc r23, r25\n" 546 | "sts (w10+1), r23\n" 547 | "sts (w10), r22\n" 548 | ); 549 | } 550 | #endif 551 | 552 | #if polyphony > 10 553 | void wave11() 554 | { 555 | asm volatile 556 | ( 557 | "lds r22, (w11)\n" 558 | "lds r23, (w11+1)\n" 559 | "lds r24, (w11+2)\n" 560 | "lds r25, (w11+3)\n" 561 | "lds r21, (w11+4)\n" 562 | "add r22, r24\n" 563 | "adc r23, r25\n" 564 | "sts (w11+1), r23\n" 565 | "sts (w11), r22\n" 566 | ); 567 | } 568 | #endif 569 | 570 | #if polyphony > 11 571 | void wave12() 572 | { 573 | asm volatile 574 | ( 575 | "lds r22, (w12)\n" 576 | "lds r23, (w12+1)\n" 577 | "lds r24, (w12+2)\n" 578 | "lds r25, (w12+3)\n" 579 | "lds r21, (w12+4)\n" 580 | "add r22, r24\n" 581 | "adc r23, r25\n" 582 | "sts (w12+1), r23\n" 583 | "sts (w12), r22\n" 584 | ); 585 | } 586 | #endif 587 | 588 | #if polyphony > 12 589 | void wave13() 590 | { 591 | asm volatile 592 | ( 593 | "lds r22, (w13)\n" 594 | "lds r23, (w13+1)\n" 595 | "lds r24, (w13+2)\n" 596 | "lds r25, (w13+3)\n" 597 | "lds r21, (w13+4)\n" 598 | "add r22, r24\n" 599 | "adc r23, r25\n" 600 | "sts (w13+1), r23\n" 601 | "sts (w13), r22\n" 602 | ); 603 | } 604 | #endif 605 | 606 | #if polyphony > 13 607 | void wave14() 608 | { 609 | asm volatile 610 | ( 611 | "lds r22, (w14)\n" 612 | "lds r23, (w14+1)\n" 613 | "lds r24, (w14+2)\n" 614 | "lds r25, (w14+3)\n" 615 | "lds r21, (w14+4)\n" 616 | "add r22, r24\n" 617 | "adc r23, r25\n" 618 | "sts (w14+1), r23\n" 619 | "sts (w14), r22\n" 620 | ); 621 | } 622 | #endif 623 | 624 | #if polyphony > 14 625 | void wave15() 626 | { 627 | asm volatile 628 | ( 629 | "lds r22, (w15)\n" 630 | "lds r23, (w15+1)\n" 631 | "lds r24, (w15+2)\n" 632 | "lds r25, (w15+3)\n" 633 | "lds r21, (w15+4)\n" 634 | "add r22, r24\n" 635 | "adc r23, r25\n" 636 | "sts (w15+1), r23\n" 637 | "sts (w15), r22\n" 638 | ); 639 | } 640 | #endif 641 | 642 | #if polyphony > 15 643 | void wave16() 644 | { 645 | asm volatile 646 | ( 647 | "lds r22, (w16)\n" 648 | "lds r23, (w16+1)\n" 649 | "lds r24, (w16+2)\n" 650 | "lds r25, (w16+3)\n" 651 | "lds r21, (w16+4)\n" 652 | "add r22, r24\n" 653 | "adc r23, r25\n" 654 | "sts (w16+1), r23\n" 655 | "sts (w16), r22\n" 656 | ); 657 | } 658 | #endif 659 | 660 | #if polyphony > 16 661 | void wave17() 662 | { 663 | asm volatile 664 | ( 665 | "lds r22, (w17)\n" 666 | "lds r23, (w17+1)\n" 667 | "lds r24, (w17+2)\n" 668 | "lds r25, (w17+3)\n" 669 | "lds r21, (w17+4)\n" 670 | "add r22, r24\n" 671 | "adc r23, r25\n" 672 | "sts (w17+1), r23\n" 673 | "sts (w17), r22\n" 674 | ); 675 | } 676 | #endif 677 | 678 | #if polyphony > 17 679 | void wave18() 680 | { 681 | asm volatile 682 | ( 683 | "lds r22, (w18)\n" 684 | "lds r23, (w18+1)\n" 685 | "lds r24, (w18+2)\n" 686 | "lds r25, (w18+3)\n" 687 | "lds r21, (w18+4)\n" 688 | "add r22, r24\n" 689 | "adc r23, r25\n" 690 | "sts (w18+1), r23\n" 691 | "sts (w18), r22\n" 692 | ); 693 | } 694 | #endif 695 | 696 | #if polyphony > 18 697 | void wave19() 698 | { 699 | asm volatile 700 | ( 701 | "lds r22, (w19)\n" 702 | "lds r23, (w19+1)\n" 703 | "lds r24, (w19+2)\n" 704 | "lds r25, (w19+3)\n" 705 | "lds r21, (w19+4)\n" 706 | "add r22, r24\n" 707 | "adc r23, r25\n" 708 | "sts (w19+1), r23\n" 709 | "sts (w19), r22\n" 710 | ); 711 | } 712 | #endif 713 | 714 | #if polyphony > 19 715 | void wave20() 716 | { 717 | asm volatile 718 | ( 719 | "lds r22, (w20)\n" 720 | "lds r23, (w20+1)\n" 721 | "lds r24, (w20+2)\n" 722 | "lds r25, (w20+3)\n" 723 | "lds r21, (w20+4)\n" 724 | "add r22, r24\n" 725 | "adc r23, r25\n" 726 | "sts (w20+1), r23\n" 727 | "sts (w20), r22\n" 728 | ); 729 | } 730 | #endif 731 | 732 | #if polyphony > 20 733 | void wave21() 734 | { 735 | asm volatile 736 | ( 737 | "lds r22, (w21)\n" 738 | "lds r23, (w21+1)\n" 739 | "lds r24, (w21+2)\n" 740 | "lds r25, (w21+3)\n" 741 | "lds r21, (w21+4)\n" 742 | "add r22, r24\n" 743 | "adc r23, r25\n" 744 | "sts (w21+1), r23\n" 745 | "sts (w21), r22\n" 746 | ); 747 | } 748 | #endif 749 | 750 | #if polyphony > 21 751 | void wave22() 752 | { 753 | asm volatile 754 | ( 755 | "lds r22, (w22)\n" 756 | "lds r23, (w22+1)\n" 757 | "lds r24, (w22+2)\n" 758 | "lds r25, (w22+3)\n" 759 | "lds r21, (w22+4)\n" 760 | "add r22, r24\n" 761 | "adc r23, r25\n" 762 | "sts (w22+1), r23\n" 763 | "sts (w22), r22\n" 764 | ); 765 | } 766 | #endif 767 | 768 | #if polyphony > 22 769 | void wave23() 770 | { 771 | asm volatile 772 | ( 773 | "lds r22, (w23)\n" 774 | "lds r23, (w23+1)\n" 775 | "lds r24, (w23+2)\n" 776 | "lds r25, (w23+3)\n" 777 | "lds r21, (w23+4)\n" 778 | "add r22, r24\n" 779 | "adc r23, r25\n" 780 | "sts (w23+1), r23\n" 781 | "sts (w23), r22\n" 782 | ); 783 | } 784 | #endif 785 | 786 | #if polyphony > 23 787 | void wave24() 788 | { 789 | asm volatile 790 | ( 791 | "lds r22, (w24)\n" 792 | "lds r23, (w24+1)\n" 793 | "lds r24, (w24+2)\n" 794 | "lds r25, (w24+3)\n" 795 | "lds r21, (w24+4)\n" 796 | "add r22, r24\n" 797 | "adc r23, r25\n" 798 | "sts (w24+1), r23\n" 799 | "sts (w24), r22\n" 800 | ); 801 | } 802 | #endif 803 | 804 | #if polyphony > 24 805 | void wave25() 806 | { 807 | asm volatile 808 | ( 809 | "lds r22, (w25)\n" 810 | "lds r23, (w25+1)\n" 811 | "lds r24, (w25+2)\n" 812 | "lds r25, (w25+3)\n" 813 | "lds r21, (w25+4)\n" 814 | "add r22, r24\n" 815 | "adc r23, r25\n" 816 | "sts (w25+1), r23\n" 817 | "sts (w25), r22\n" 818 | ); 819 | } 820 | #endif 821 | 822 | #if polyphony > 25 823 | void wave26() 824 | { 825 | asm volatile 826 | ( 827 | "lds r22, (w26)\n" 828 | "lds r23, (w26+1)\n" 829 | "lds r24, (w26+2)\n" 830 | "lds r25, (w26+3)\n" 831 | "lds r21, (w26+4)\n" 832 | "add r22, r24\n" 833 | "adc r23, r25\n" 834 | "sts (w26+1), r23\n" 835 | "sts (w26), r22\n" 836 | ); 837 | } 838 | #endif 839 | 840 | #if polyphony > 26 841 | void wave27() 842 | { 843 | asm volatile 844 | ( 845 | "lds r22, (w27)\n" 846 | "lds r23, (w27+1)\n" 847 | "lds r24, (w27+2)\n" 848 | "lds r25, (w27+3)\n" 849 | "lds r21, (w27+4)\n" 850 | "add r22, r24\n" 851 | "adc r23, r25\n" 852 | "sts (w27+1), r23\n" 853 | "sts (w27), r22\n" 854 | ); 855 | } 856 | #endif 857 | 858 | #if polyphony > 27 859 | void wave28() 860 | { 861 | asm volatile 862 | ( 863 | "lds r22, (w28)\n" 864 | "lds r23, (w28+1)\n" 865 | "lds r24, (w28+2)\n" 866 | "lds r25, (w28+3)\n" 867 | "lds r21, (w28+4)\n" 868 | "add r22, r24\n" 869 | "adc r23, r25\n" 870 | "sts (w28+1), r23\n" 871 | "sts (w28), r22\n" 872 | ); 873 | } 874 | #endif 875 | 876 | #if polyphony > 28 877 | void wave29() 878 | { 879 | asm volatile 880 | ( 881 | "lds r22, (w29)\n" 882 | "lds r23, (w29+1)\n" 883 | "lds r24, (w29+2)\n" 884 | "lds r25, (w29+3)\n" 885 | "lds r21, (w29+4)\n" 886 | "add r22, r24\n" 887 | "adc r23, r25\n" 888 | "sts (w29+1), r23\n" 889 | "sts (w29), r22\n" 890 | ); 891 | } 892 | #endif 893 | 894 | #if polyphony > 29 895 | void wave30() 896 | { 897 | asm volatile 898 | ( 899 | "lds r22, (w30)\n" 900 | "lds r23, (w30+1)\n" 901 | "lds r24, (w30+2)\n" 902 | "lds r25, (w30+3)\n" 903 | "lds r21, (w30+4)\n" 904 | "add r22, r24\n" 905 | "adc r23, r25\n" 906 | "sts (w30+1), r23\n" 907 | "sts (w30), r22\n" 908 | ); 909 | } 910 | #endif 911 | 912 | #if polyphony > 30 913 | void wave31() 914 | { 915 | asm volatile 916 | ( 917 | "lds r22, (w31)\n" 918 | "lds r23, (w31+1)\n" 919 | "lds r24, (w31+2)\n" 920 | "lds r25, (w31+3)\n" 921 | "lds r21, (w31+4)\n" 922 | "add r22, r24\n" 923 | "adc r23, r25\n" 924 | "sts (w31+1), r23\n" 925 | "sts (w31), r22\n" 926 | ); 927 | } 928 | #endif 929 | 930 | #if polyphony > 31 931 | void wave32() 932 | { 933 | asm volatile 934 | ( 935 | "lds r22, (w32)\n" 936 | "lds r23, (w32+1)\n" 937 | "lds r24, (w32+2)\n" 938 | "lds r25, (w32+3)\n" 939 | "lds r21, (w32+4)\n" 940 | "add r22, r24\n" 941 | "adc r23, r25\n" 942 | "sts (w32+1), r23\n" 943 | "sts (w32), r22\n" 944 | ); 945 | } 946 | #endif 947 | 948 | #endif -------------------------------------------------------------------------------- /src/asmsynth.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ezasm/asmsynth/20f70289c53cce63a063fa63b9c6385da021640d/src/asmsynth.h -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #ifndef config 2 | #define config 3 | 4 | 5 | 6 | 7 | 8 | //main setting: 9 | #define polyphony 16 10 | #define mode 1 11 | #define channel 1 12 | 13 | //io setting: 14 | #define timerInterrupt 2 15 | #define PWM1 11 16 | //#define PWM2 10 17 | //#define PWM3 9 18 | //#define PWM4 3 19 | //#define pin1 10 20 | //#define pin2 9 21 | //#define pin3 5 22 | //#define pin4 6 23 | 24 | 25 | //additional options: 26 | //#define disable_volume 27 | //#define disable_secondProgram 28 | //#define enable_highSamplingRate 29 | //#define enable_motor 30 | //#define enable_ADC 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | //manual mode: 46 | //timerInterrupt: 47 | //#define vectorInterrupt __vector_0 48 | //#define asm_STI_25 sts 0x00, r25 49 | //#define asm_LTI_25 lds r25, 0x00 50 | //PWM: 51 | //PWM1: 52 | //#define C_PWM1_21 "sts 0x00, r21\n" 53 | //#define asm_PWM1_24 sts 0x00, r24 54 | //PWM2: 55 | //#define C_PWM2_20 "sts 0x00, r20\n" 56 | //#define C_PWM2_21 "sts 0x00, r21\n" 57 | //#define asm_PWM2_24 sts 0x00, r24 58 | //PWM3: 59 | //#define C_PWM3_20 "sts 0x00, r20\n" 60 | //#define asm_PWM3_24 sts 0x00, r24 61 | //PWM4: 62 | //#define C_PWM4_20 "sts 0x00, r20\n" 63 | //#define asm_PWM4_24 sts 0x00, r24 64 | //pins: 65 | //pin1: 66 | //#define C_Cpin1 "cbi 0x00, 0\n" 67 | //#define C_Spin1 "sbi 0x00, 0\n" 68 | //#define asm_Cpin1 cbi 0x00, 0 69 | //#define asm_Spin1 sbi 0x00, 0 70 | //pin2: 71 | //#define C_Cpin2 "cbi 0x00, 0\n" 72 | //#define C_Spin2 "sbi 0x00, 0\n" 73 | //#define asm_Cpin2 cbi 0x00, 0 74 | //#define asm_Spin2 sbi 0x00, 0 75 | //pin3: 76 | //#define C_Cpin3 "cbi 0x00, 0\n" 77 | //#define C_Spin3 "sbi 0x00, 0\n" 78 | //#define asm_Cpin3 cbi 0x00, 0 79 | //#define asm_Spin3 sbi 0x00, 0 80 | //pin4: 81 | //#define C_Cpin4 "cbi 0x00, 0\n" 82 | //#define C_Spin4 "sbi 0x00, 0\n" 83 | //#define asm_Cpin4 cbi 0x00, 0 84 | //#define asm_Spin4 sbi 0x00, 0 85 | 86 | 87 | 88 | 89 | 90 | #include 91 | #endif -------------------------------------------------------------------------------- /src/iosupport.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ezasm/asmsynth/20f70289c53cce63a063fa63b9c6385da021640d/src/iosupport.h --------------------------------------------------------------------------------