vibrato and polyphony paratmeters
This commit is contained in:
		
							parent
							
								
									d3fc077fa3
								
							
						
					
					
						commit
						fd49dfe5cb
					
				
					 3 changed files with 249 additions and 159 deletions
				
			
		
							
								
								
									
										140
									
								
								quantum/audio.h
									
										
									
									
									
								
							
							
						
						
									
										140
									
								
								quantum/audio.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@
 | 
			
		|||
#ifndef AUDIO_H
 | 
			
		||||
#define AUDIO_H
 | 
			
		||||
 | 
			
		||||
// Enable vibrato strength/amplitude - slows down ISR too much
 | 
			
		||||
// #define VIBRATO_STRENGTH_ENABLE
 | 
			
		||||
 | 
			
		||||
typedef union {
 | 
			
		||||
    uint8_t raw;
 | 
			
		||||
    struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +23,34 @@ void audio_toggle(void);
 | 
			
		|||
void audio_on(void);
 | 
			
		||||
void audio_off(void);
 | 
			
		||||
 | 
			
		||||
// Vibrato rate functions
 | 
			
		||||
 | 
			
		||||
void set_vibrato_rate(float rate);
 | 
			
		||||
void increase_vibrato_rate(float change);
 | 
			
		||||
void decrease_vibrato_rate(float change);
 | 
			
		||||
 | 
			
		||||
#ifdef VIBRATO_STRENGTH_ENABLE
 | 
			
		||||
 | 
			
		||||
void set_vibrato_strength(float strength);
 | 
			
		||||
void increase_vibrato_strength(float change);
 | 
			
		||||
void decrease_vibrato_strength(float change);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Polyphony functions
 | 
			
		||||
 | 
			
		||||
void set_polyphony_rate(float rate);
 | 
			
		||||
void enable_polyphony();
 | 
			
		||||
void disable_polyphony();
 | 
			
		||||
void increase_polyphony_rate(float change);
 | 
			
		||||
void decrease_polyphony_rate(float change);
 | 
			
		||||
 | 
			
		||||
void set_timbre(float timbre);
 | 
			
		||||
void set_tempo(float tempo);
 | 
			
		||||
 | 
			
		||||
void increase_tempo(uint8_t tempo_change);
 | 
			
		||||
void decrease_tempo(uint8_t tempo_change);
 | 
			
		||||
 | 
			
		||||
void play_sample(uint8_t * s, uint16_t l, bool r);
 | 
			
		||||
void play_note(double freq, int vol);
 | 
			
		||||
void stop_note(double freq);
 | 
			
		||||
| 
						 | 
				
			
			@ -27,11 +58,6 @@ void stop_all_notes(void);
 | 
			
		|||
void init_notes(void);
 | 
			
		||||
void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest);
 | 
			
		||||
 | 
			
		||||
void set_timbre(float timbre);
 | 
			
		||||
void set_tempo(float tempo);
 | 
			
		||||
void increase_tempo(uint8_t tempo_change);
 | 
			
		||||
void decrease_tempo(uint8_t tempo_change);
 | 
			
		||||
 | 
			
		||||
#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
 | 
			
		||||
						0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
 | 
			
		||||
						0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
 | 
			
		||||
| 
						 | 
				
			
			@ -47,108 +73,4 @@ void decrease_tempo(uint8_t tempo_change);
 | 
			
		|||
void play_goodbye_tone(void);
 | 
			
		||||
void play_startup_tone(void);
 | 
			
		||||
 | 
			
		||||
#define VIBRATO_LUT (float []) { \
 | 
			
		||||
1.00090714186239, \
 | 
			
		||||
1.00181152169061, \
 | 
			
		||||
1.00270955652027, \
 | 
			
		||||
1.00359767896099, \
 | 
			
		||||
1.00447235162891, \
 | 
			
		||||
1.00533008160601, \
 | 
			
		||||
1.00616743486158, \
 | 
			
		||||
1.00698105056935, \
 | 
			
		||||
1.00776765525194, \
 | 
			
		||||
1.00852407668313, \
 | 
			
		||||
1.0092472574777, \
 | 
			
		||||
1.00993426829815, \
 | 
			
		||||
1.01058232060837, \
 | 
			
		||||
1.01118877890462, \
 | 
			
		||||
1.01175117235612, \
 | 
			
		||||
1.01226720578933, \
 | 
			
		||||
1.01273476995269, \
 | 
			
		||||
1.01315195100182, \
 | 
			
		||||
1.0135170391489, \
 | 
			
		||||
1.01382853642434, \
 | 
			
		||||
1.01408516350345, \
 | 
			
		||||
1.01428586555648, \
 | 
			
		||||
1.0144298170856, \
 | 
			
		||||
1.0145164257189, \
 | 
			
		||||
1.01454533493752, \
 | 
			
		||||
1.0145164257189, \
 | 
			
		||||
1.0144298170856, \
 | 
			
		||||
1.01428586555648, \
 | 
			
		||||
1.01408516350345, \
 | 
			
		||||
1.01382853642434, \
 | 
			
		||||
1.0135170391489, \
 | 
			
		||||
1.01315195100182, \
 | 
			
		||||
1.01273476995269, \
 | 
			
		||||
1.01226720578933, \
 | 
			
		||||
1.01175117235612, \
 | 
			
		||||
1.01118877890462, \
 | 
			
		||||
1.01058232060837, \
 | 
			
		||||
1.00993426829815, \
 | 
			
		||||
1.0092472574777, \
 | 
			
		||||
1.00852407668313, \
 | 
			
		||||
1.00776765525194, \
 | 
			
		||||
1.00698105056935, \
 | 
			
		||||
1.00616743486158, \
 | 
			
		||||
1.00533008160601, \
 | 
			
		||||
1.00447235162891, \
 | 
			
		||||
1.00359767896099, \
 | 
			
		||||
1.00270955652027, \
 | 
			
		||||
1.00181152169061, \
 | 
			
		||||
1.00090714186239, \
 | 
			
		||||
1, \
 | 
			
		||||
0.999093680298157, \
 | 
			
		||||
0.998191753986265, \
 | 
			
		||||
0.997297765337276, \
 | 
			
		||||
0.996415217934032, \
 | 
			
		||||
0.995547561242821, \
 | 
			
		||||
0.99469817754036, \
 | 
			
		||||
0.993870369236874, \
 | 
			
		||||
0.993067346634376, \
 | 
			
		||||
0.992292216155724, \
 | 
			
		||||
0.991547969076588, \
 | 
			
		||||
0.990837470789065, \
 | 
			
		||||
0.990163450622494, \
 | 
			
		||||
0.989528492243954, \
 | 
			
		||||
0.988935024658062, \
 | 
			
		||||
0.988385313823004, \
 | 
			
		||||
0.98788145489731, \
 | 
			
		||||
0.987425365129624, \
 | 
			
		||||
0.987018777401739, \
 | 
			
		||||
0.986663234433381, \
 | 
			
		||||
0.986360083655655, \
 | 
			
		||||
0.986110472758728, \
 | 
			
		||||
0.985915345918143, \
 | 
			
		||||
0.985775440703176, \
 | 
			
		||||
0.985691285669809, \
 | 
			
		||||
0.985663198640188, \
 | 
			
		||||
0.985691285669809, \
 | 
			
		||||
0.985775440703176, \
 | 
			
		||||
0.985915345918143, \
 | 
			
		||||
0.986110472758728, \
 | 
			
		||||
0.986360083655655, \
 | 
			
		||||
0.986663234433381, \
 | 
			
		||||
0.987018777401739, \
 | 
			
		||||
0.987425365129624, \
 | 
			
		||||
0.98788145489731, \
 | 
			
		||||
0.988385313823004, \
 | 
			
		||||
0.988935024658062, \
 | 
			
		||||
0.989528492243954, \
 | 
			
		||||
0.990163450622494, \
 | 
			
		||||
0.990837470789065, \
 | 
			
		||||
0.991547969076588, \
 | 
			
		||||
0.992292216155724, \
 | 
			
		||||
0.993067346634376, \
 | 
			
		||||
0.993870369236874, \
 | 
			
		||||
0.99469817754036, \
 | 
			
		||||
0.99554756124282, \
 | 
			
		||||
0.996415217934032, \
 | 
			
		||||
0.997297765337276, \
 | 
			
		||||
0.998191753986265, \
 | 
			
		||||
0.999093680298157, \
 | 
			
		||||
1, \
 | 
			
		||||
}
 | 
			
		||||
#define VIBRATO_LUT_LENGTH NOTE_ARRAY_SIZE(VIBRATO_LUT)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue