Skip to content

Commit 00a7581

Browse files
author
Tonsuke
committed
no message
1 parent 8bee7b5 commit 00a7581

File tree

9 files changed

+320
-32
lines changed

9 files changed

+320
-32
lines changed

fx.c

+42
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,48 @@ void IIR_Filter(IIR_Filter_Struct_Typedef *IIR, uint32_t *out_ptr, float *sout_p
200200
}
201201
}
202202

203+
void IIR_resonator(float fc, float Q, float a[], float b[])
204+
{
205+
fc = tanf(M_PI_F * fc) / (2.0f * M_PI_F);
206+
207+
a[0] = 1.0f + 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc;
208+
a[1] = (8.0f * M_PI_F * M_PI_F * fc * fc - 2.0f) / a[0];
209+
a[2] = (1.0f - 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc) / a[0];
210+
b[0] = 2.0f * M_PI_F * fc / Q / a[0];
211+
b[1] = 0.0f;
212+
b[2] = -2.0f * M_PI_F * fc / Q / a[0];
213+
214+
a[0] = 1.0f;
215+
}
216+
217+
void IIR_LPF(float fc, float Q, float a[], float b[])
218+
{
219+
fc = tanf(M_PI_F * fc) / (2.0f * M_PI_F);
220+
221+
a[0] = 1.0f + 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc;
222+
a[1] = (8.0f * M_PI_F * M_PI_F * fc * fc - 2.0f) / a[0];
223+
a[2] = (1.0f - 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc) / a[0];
224+
b[0] = 4.0f * M_PI_F * M_PI_F * fc * fc / a[0];
225+
b[1] = 8.0f * M_PI_F * M_PI_F * fc * fc / a[0];
226+
b[2] = 4.0f * M_PI_F * M_PI_F * fc * fc / a[0];
227+
228+
a[0] = 1.0f;
229+
}
230+
231+
void IIR_HPF(float fc, float Q, float a[], float b[])
232+
{
233+
fc = tanf(M_PI_F * fc) / (2.0f * M_PI_F);
234+
235+
a[0] = 1.0f + 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc;
236+
a[1] = (8.0f * M_PI_F * M_PI_F * fc * fc - 2.0f) / a[0];
237+
a[2] = (1.0f - 2.0f * M_PI_F * fc / Q + 4.0f * M_PI_F * M_PI_F * fc * fc) / a[0];
238+
b[0] = 1.0f / a[0];
239+
b[1] = -2.0f / a[0];
240+
b[2] = 1.0f / a[0];
241+
242+
a[0] = 1.0f;
243+
}
244+
203245
void IIR_low_shelving(float fc, float Q, float g, float a[], float b[])
204246
{
205247
fc = tanf(M_PI_F * fc) / (2.0f * M_PI_F);

fx.h

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern void REVERB_Init(REVERB_Struct_Typedef *RFX, int n);
3838
extern void REVERB(REVERB_Struct_Typedef *RFX, uint32_t *out_ptr);
3939
extern void IIR_Set_Params(IIR_Filter_Struct_Typedef *IIR);
4040
extern void IIR_Filter(IIR_Filter_Struct_Typedef *IIR, uint32_t *out_ptr, float *sout_ptr_A, float *sout_ptr_B);
41+
extern void IIR_resonator(float fc, float Q, float a[], float b[]);
42+
extern void IIR_LPF(float fc, float Q, float a[], float b[]);
43+
extern void IIR_HPF(float fc, float Q, float a[], float b[]);
4144
extern void IIR_low_shelving(float fc, float Q, float g, float a[], float b[]);
4245
extern void IIR_peaking(float fc, float Q, float g, float a[], float b[]);
4346

jpeg-7/jdmaster.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,32 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
407407
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
408408
}
409409

410+
void
411+
prepare_range_limit_table2 (JSAMPLE *jpeg_limit_table, j_decompress_ptr cinfo)
412+
/* Allocate and fill in the sample_range_limit table */
413+
{
414+
JSAMPLE * table;
415+
int i;
416+
417+
table = jpeg_limit_table;
418+
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
419+
cinfo->sample_range_limit = table;
420+
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
421+
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
422+
/* Main part of "simple" table: limit[x] = x */
423+
for (i = 0; i <= MAXJSAMPLE; i++)
424+
table[i] = (JSAMPLE) i;
425+
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
426+
/* End of simple table, rest of first half of post-IDCT table */
427+
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
428+
table[i] = MAXJSAMPLE;
429+
/* Second half of post-IDCT table */
430+
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
431+
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
432+
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
433+
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
434+
}
435+
410436

411437
/*
412438
* Master selection of decompression modules.
@@ -435,8 +461,8 @@ master_selection (j_decompress_ptr cinfo)
435461
cinfo->min_DCT_v_scaled_size = DCTSIZE;
436462
} else {
437463
jpeg_calc_output_dimensions(cinfo);
464+
prepare_range_limit_table(cinfo);
438465
}
439-
prepare_range_limit_table(cinfo);
440466

441467
/* Width of an output scanline must be representable as JDIMENSION. */
442468
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;

jpeg-7/jdmerge.c

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
338338
pixel.color.B = range_limit[y + cblue] >> 3;
339339
pixel.color.G = range_limit[y + cgreen] >> 2;
340340
pixel.color.R = range_limit[y + cred] >> 3;
341+
341342
LCD->RAM = pixel.color.d16;
342343
// LCD->RAM = range_limit[y + cblue] >> 3 | (range_limit[y + cgreen] >> 2) << 5 | (range_limit[y + cred] >> 3) << 11;
343344

lcd.c

+208
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,214 @@ void LCDPutBgImgMusic(){
901901
}
902902
}
903903

904+
void DrawLine(int x1, int y1, int x2, int y2, colors color)
905+
{
906+
int W = x2 - x1;
907+
int H = y2 - y1;
908+
int dx = 0;
909+
int dy = 0;
910+
int Wy = 0;
911+
int Hx = 0;
912+
if (W >= H)
913+
{
914+
for (dx = 0; dx <= W; dx ++)
915+
{
916+
LCDSetGramAddr(x1+dx, y1+dy);
917+
LCDPutCmd(0x0022);
918+
LCDPutData(colorc[color]);
919+
Hx += H;
920+
if (Wy < Hx)
921+
{
922+
Wy += W;
923+
dy += 1;
924+
}
925+
}
926+
}
927+
else
928+
{
929+
for (dy = 0; dy <= H; dy ++)
930+
{
931+
LCDSetGramAddr(x1+dx, y1+dy);
932+
LCDPutCmd(0x0022);
933+
LCDPutData(colorc[color]);
934+
935+
Wy += W;
936+
if (Hx < Wy)
937+
{
938+
Hx += H;
939+
dx += 1;
940+
}
941+
}
942+
}
943+
}
944+
945+
__attribute__( ( always_inline ) ) __INLINE void LCDPset(uint16_t x, uint16_t y, colors color){
946+
LCDSetGramAddr(x, y);
947+
LCDPutCmd(0x0022);
948+
LCDPutData(colorc[color]);
949+
}
950+
951+
__attribute__( ( always_inline ) ) __INLINE void LCDPset2(uint16_t x, uint16_t y, uint16_t data){
952+
LCDSetGramAddr(x, y);
953+
LCDPutCmd(0x0022);
954+
LCDPutData(data);
955+
}
956+
957+
958+
__attribute__( ( always_inline ) ) __INLINE uint16_t LCDGetPos(uint16_t x, uint16_t y){
959+
LCDSetGramAddr(x, y);
960+
LCDPutCmd(0x0022);
961+
LCD->RAM;
962+
return LCD->RAM;
963+
}
964+
965+
void LCDDrawLine2(int16_t sPosX, int16_t sPosY, int16_t ePosX, int16_t ePosY, colors color){
966+
int dw, dh, e, x, y;
967+
968+
dw = ePosX - sPosX;
969+
dh = ePosY - sPosY;
970+
971+
e = 0;
972+
973+
if(dw >= dh){
974+
y = sPosY;
975+
for(x = sPosX;x <= ePosX;x++){
976+
LCDPset(x, y, color);
977+
978+
e += 2 * dh;
979+
if(e >= (2 * dw)){
980+
y++;
981+
e -= 2 * dw;
982+
}
983+
}
984+
} else{
985+
986+
}
987+
}
988+
989+
void LCDDrawLine(uint16_t sPosX, uint16_t sPosY, uint16_t ePosX, uint16_t ePosY, colors color){
990+
int x, y, w, h, offsetY;
991+
float delta, alpha;
992+
pixel_fmt_typedef pixel_fg, pixel_bg, pixel;
993+
994+
w = ePosX - sPosX;
995+
h = ePosY - sPosY;
996+
997+
// debug.printf("\r\n\nPlot");
998+
// debug.printf("\r\ndelta:%f", delta);
999+
// debug.printf("\r\noffsetY:%d", offsetY);
1000+
1001+
if(abs(w) >= abs(h)){
1002+
if(ePosX == sPosX){
1003+
offsetY = sPosY + 0.5f;
1004+
for(x = sPosX;x <= ePosX;x++){
1005+
y = offsetY;
1006+
LCDPset(x, y, color);
1007+
}
1008+
return;
1009+
}
1010+
1011+
delta = (float)h / (float)w;
1012+
offsetY = -delta * sPosX + sPosY + 0.5f;
1013+
1014+
if(ePosX >= sPosX){
1015+
for(x = sPosX;x <= ePosX;x++){
1016+
y = delta * x + offsetY;
1017+
alpha = delta * x + offsetY;
1018+
alpha = 1.0f - (alpha - y);
1019+
pixel_bg.color.d16 = LCDGetPos(x, y);
1020+
pixel_fg.color.d16 = colorc[color];
1021+
pixel.color.R = pixel_fg.color.R * alpha + pixel_bg.color.R * (1.0f - alpha);
1022+
pixel.color.G = pixel_fg.color.G * alpha + pixel_bg.color.G * (1.0f - alpha);
1023+
pixel.color.B = pixel_fg.color.B * alpha + pixel_bg.color.B * (1.0f - alpha);
1024+
LCDPset2(x, y, pixel.color.d16);
1025+
debug.printf("\r\nA x:%d y:%d delta:%f", x, y, delta);
1026+
// LCDPset(x, y, color);
1027+
}
1028+
} else {
1029+
for(x = sPosX;x >= ePosX;x--){
1030+
y = delta * x + offsetY;
1031+
1032+
alpha = delta * x + offsetY;
1033+
alpha = 1.0f - (alpha - y);
1034+
pixel_bg.color.d16 = LCDGetPos(x, y);
1035+
pixel_fg.color.d16 = colorc[color];
1036+
pixel.color.R = pixel_fg.color.R * alpha + pixel_bg.color.R * (1.0f - alpha);
1037+
pixel.color.G = pixel_fg.color.G * alpha + pixel_bg.color.G * (1.0f - alpha);
1038+
pixel.color.B = pixel_fg.color.B * alpha + pixel_bg.color.B * (1.0f - alpha);
1039+
LCDPset2(x, y, pixel.color.d16);
1040+
1041+
debug.printf("\r\nB x:%d y:%d delta:%f", x, y, delta);
1042+
// LCDPset(x, y, color);
1043+
}
1044+
}
1045+
} else {
1046+
if(ePosY >= sPosY){
1047+
if(sPosX == ePosX){
1048+
for(y = sPosY;y <= ePosY;y++){
1049+
x = sPosX;
1050+
// debug.printf("\r\nC0 x:%d y:%d delta:%f", x, y, delta);
1051+
LCDPset(x, y, color);
1052+
}
1053+
} else {
1054+
delta = (float)h / (float)w;
1055+
offsetY = -delta * sPosX + sPosY + 0.5f;
1056+
delta = 1.0f / delta;
1057+
1058+
for(y = sPosY;y <= ePosY;y++){
1059+
x = (y - offsetY) * delta;
1060+
debug.printf("\r\nC x:%d y:%d delta:%f", x, y, delta);
1061+
LCDPset(x, y, color);
1062+
1063+
alpha = (y - offsetY) * delta;
1064+
alpha = 1.0f - (alpha - x);
1065+
pixel_bg.color.d16 = LCDGetPos(x - 1, y);
1066+
pixel_fg.color.d16 = colorc[color];
1067+
pixel.color.R = pixel_fg.color.R * alpha + pixel_bg.color.R * (1.0f - alpha);
1068+
pixel.color.G = pixel_fg.color.G * alpha + pixel_bg.color.G * (1.0f - alpha);
1069+
pixel.color.B = pixel_fg.color.B * alpha + pixel_bg.color.B * (1.0f - alpha);
1070+
LCDPset2(x - 1, y, pixel.color.d16);
1071+
1072+
alpha = 1.0f - alpha;
1073+
pixel_bg.color.d16 = LCDGetPos(x + 1, y);
1074+
pixel_fg.color.d16 = colorc[color];
1075+
pixel.color.R = pixel_fg.color.R * alpha + pixel_bg.color.R * (1.0f - alpha);
1076+
pixel.color.G = pixel_fg.color.G * alpha + pixel_bg.color.G * (1.0f - alpha);
1077+
pixel.color.B = pixel_fg.color.B * alpha + pixel_bg.color.B * (1.0f - alpha);
1078+
LCDPset2(x + 1, y, pixel.color.d16);
1079+
}
1080+
}
1081+
} else {
1082+
if(sPosX == ePosX){
1083+
for(y = sPosY;y >= ePosY;y--){
1084+
x = sPosX;
1085+
// debug.printf("\r\nD0 x:%d y:%d delta:%f", x, y, delta);
1086+
LCDPset(x, y, color);
1087+
}
1088+
} else {
1089+
delta = (float)h / (float)w;
1090+
offsetY = -delta * sPosX + sPosY + 0.5f;
1091+
delta = 1.0f / delta;
1092+
1093+
for(y = sPosY;y >= ePosY;y--){
1094+
x = (y - offsetY) * delta;
1095+
alpha = (y - offsetY) * delta;
1096+
alpha = 1.0f - (alpha - x);
1097+
pixel_bg.color.d16 = LCDGetPos(x, y);
1098+
pixel_fg.color.d16 = colorc[color];
1099+
pixel.color.R = pixel_fg.color.R * alpha + pixel_bg.color.R * (1.0f - alpha);
1100+
pixel.color.G = pixel_fg.color.G * alpha + pixel_bg.color.G * (1.0f - alpha);
1101+
pixel.color.B = pixel_fg.color.B * alpha + pixel_bg.color.B * (1.0f - alpha);
1102+
LCDPset2(x, y, pixel.color.d16);
1103+
1104+
debug.printf("\r\nD x:%d y:%d delta:%f", x, y, delta);
1105+
// LCDPset(x, y, color);
1106+
}
1107+
}
1108+
}
1109+
}
1110+
1111+
}
9041112

9051113
void LCDDrawSquare(uint16_t x, uint16_t y, uint16_t width, uint16_t height, colors color)
9061114
{

0 commit comments

Comments
 (0)