fix duty cycle offset
This commit is contained in:
parent
20ae092592
commit
5ee050e0c4
BIN
data/bg.png
BIN
data/bg.png
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
53
knob.h
53
knob.h
|
@ -4,38 +4,29 @@
|
|||
#include<stdint.h>
|
||||
#include<string.h>
|
||||
|
||||
#define K_AMP 0
|
||||
#define K_FREQ 1
|
||||
#define K_OSC1_VOL 2
|
||||
#define K_OSC1_WAVEF 3
|
||||
#define K_OSC1_PHASE 4
|
||||
#define K_OSC1_DET 22
|
||||
#define K_OSC2_VOL 5
|
||||
#define K_OSC2_WAVEF 6
|
||||
#define K_OSC2_PHASE 7
|
||||
#define K_OSC2_DET 23
|
||||
#define K_OSC3_VOL 8
|
||||
#define K_OSC3_WAVEF 9
|
||||
#define K_OSC3_PHASE 10
|
||||
#define K_OSC3_DET 24
|
||||
#define K_OSC4_VOL 11
|
||||
#define K_OSC4_WAVEF 12
|
||||
#define K_OSC4_PHASE 13
|
||||
#define K_OSC4_DET 25
|
||||
#define K_HP 14
|
||||
#define K_LP 15
|
||||
#define K_AENV_ATK 16
|
||||
#define K_AENV_REL 17
|
||||
#define K_FENV_ATK 18
|
||||
#define K_FENV_REL 19
|
||||
#define K_DET 20
|
||||
#define K_LIM 21
|
||||
// Knob indexes
|
||||
enum
|
||||
{
|
||||
K_AMP, K_FREQ, K_DET, K_LIM,
|
||||
K_AENV_ATK, K_AENV_REL,
|
||||
K_OSC1_VOL, K_OSC1_WAVEF, K_OSC1_PHASE, K_OSC1_DET,
|
||||
K_OSC2_VOL, K_OSC2_WAVEF, K_OSC2_PHASE, K_OSC2_DET,
|
||||
K_OSC3_VOL, K_OSC3_WAVEF, K_OSC3_PHASE, K_OSC3_DET,
|
||||
K_OSC4_VOL, K_OSC4_WAVEF, K_OSC4_PHASE, K_OSC4_DET,
|
||||
K_HP, K_LP,
|
||||
K_FENV_ATK, K_FENV_REL,
|
||||
K_LFO1_VOL,
|
||||
};
|
||||
|
||||
#define K_FMT_PERC 0 // Percent
|
||||
#define K_FMT_FLOAT 1
|
||||
#define K_FMT_WAV 2
|
||||
#define K_FMT_FREQ 3
|
||||
#define K_FMT_HEX 4
|
||||
// Knob value display formats
|
||||
enum
|
||||
{
|
||||
K_FMT_PERC,
|
||||
K_FMT_FLOAT,
|
||||
K_FMT_WAV,
|
||||
K_FMT_FREQ,
|
||||
K_FMT_HEX,
|
||||
};
|
||||
|
||||
typedef struct Knob
|
||||
{
|
||||
|
|
51
main.c
51
main.c
|
@ -107,48 +107,50 @@ int main(void)
|
|||
|
||||
// Create knobs
|
||||
{
|
||||
uint32_t x=0+12;
|
||||
uint32_t y=164;
|
||||
const uint32_t cell_w=153,cell_h=75;
|
||||
const uint32_t cell_padx=16,cell_pady=18;
|
||||
uint32_t x=0+cell_padx;
|
||||
uint32_t y=cell_h+cell_pady;
|
||||
#define knob_space 32
|
||||
create_knob(knobs+K_OSC1_VOL,"",x,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC1_WAVEF,"",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC1_PHASE,"Phs",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC1_DET,"Fine",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152+12;
|
||||
x=cell_w+cell_padx;
|
||||
create_knob(knobs+K_OSC2_VOL,"",x,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC2_WAVEF,"",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC2_PHASE,"Phs",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC2_DET,"Fine",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152*2+12;
|
||||
x=cell_w*2+cell_padx;
|
||||
create_knob(knobs+K_OSC3_VOL,"",x,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC3_WAVEF,"",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC3_PHASE,"Phs",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC3_DET,"Fine",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152*3+12;
|
||||
x=cell_w*3+cell_padx;
|
||||
create_knob(knobs+K_OSC4_VOL,"",x,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC4_WAVEF,"",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC4_PHASE,"Phs",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_OSC4_DET,"Fine",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=0+12;
|
||||
y=148+90;
|
||||
x=0+cell_padx;
|
||||
y+=75;
|
||||
create_knob(knobs+K_AMP,"Amp",x,y);++total_knobs;
|
||||
create_knob(knobs+K_LIM,"Lim",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_DET,"Fine",x+=knob_space,y);++total_knobs;
|
||||
create_knob(knobs+K_FREQ,"",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152*1+12;
|
||||
x=cell_w*1+cell_padx;
|
||||
create_knob(knobs+K_AENV_ATK,"A",x,y);++total_knobs;
|
||||
create_knob(knobs+K_AENV_REL,"R",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152*2+12;
|
||||
x=cell_w*2+cell_padx;
|
||||
create_knob(knobs+K_LP,"LP",x,y);++total_knobs;
|
||||
create_knob(knobs+K_HP,"HP",x+=knob_space,y);++total_knobs;
|
||||
|
||||
x=152*3+12;
|
||||
x=cell_w*3+cell_padx;
|
||||
create_knob(knobs+K_FENV_ATK,"A",x,y);++total_knobs;
|
||||
create_knob(knobs+K_FENV_REL,"R",x+=knob_space,y);++total_knobs;
|
||||
#undef knob_space
|
||||
|
@ -604,21 +606,24 @@ int main(void)
|
|||
render_image(r,tex_bg,0,0,640,480);
|
||||
|
||||
// Draw waveform
|
||||
SDL_SetRenderDrawColor(r,86,86,86,86);
|
||||
SDL_RenderDrawLine(r,0,70,640,70);
|
||||
SDL_SetRenderDrawColor(r,255,0,0,0);
|
||||
for(size_t i=1;i<SONGSIZE;++i)
|
||||
{
|
||||
float y1=MIN(synth.channel[0][i-1],1.0);
|
||||
float y2=MIN(synth.channel[0][i],1.0);
|
||||
SDL_RenderDrawLine(r,
|
||||
((float)i-1)/SONGSIZE*640,MIN(70-y1*70,140),
|
||||
((float)i)/SONGSIZE*640,MIN(70-y2*70,140)
|
||||
);
|
||||
const uint32_t wf_x=0,wf_y=0,wf_w=153,wf_h=75;
|
||||
SDL_SetRenderDrawColor(r,86,86,86,86);
|
||||
SDL_RenderDrawLine(r,wf_x,wf_y+wf_h/2,wf_w,wf_h/2);
|
||||
SDL_SetRenderDrawColor(r,255,0,0,0);
|
||||
for(size_t i=1;i<SONGSIZE;++i)
|
||||
{
|
||||
float y1=MIN(synth.channel[0][i-1],1.0);
|
||||
float y2=MIN(synth.channel[0][i],1.0);
|
||||
SDL_RenderDrawLine(r,
|
||||
wf_x+((float)i-1)/SONGSIZE*wf_w,wf_y+MIN(wf_h/2-y1*wf_h,wf_h),
|
||||
wf_x+((float)i)/SONGSIZE*wf_w,wf_y+MIN(wf_h/2-y2*wf_h,wf_h)
|
||||
);
|
||||
}
|
||||
/* SDL_SetRenderDrawColor(r,255,255,255,255); */
|
||||
/* SDL_RenderDrawLine(r,0,0,640,0); */
|
||||
/* SDL_RenderDrawLine(r,0,80*2,640,80*2); */
|
||||
}
|
||||
/* SDL_SetRenderDrawColor(r,255,255,255,255); */
|
||||
/* SDL_RenderDrawLine(r,0,0,640,0); */
|
||||
/* SDL_RenderDrawLine(r,0,80*2,640,80*2); */
|
||||
|
||||
// Spectrum analyzer?
|
||||
/* { */
|
||||
|
|
Loading…
Reference in New Issue
Block a user