History

New feature: Draw C-4 (mid-C) frequency in Inster. Ed.

Olav Sørensen committed 5 years ago

Commit b48f9f21 parent 90021933 files · +35 −63Browse files

Unified · Split

3 files
  1. src/ft2_inst_ed.c +32 −58
  2. src/ft2_inst_ed.h +2 −0
  3. src/ft2_sample_ed.c +1 −5
src/ft2_inst_ed.c+32−58
@@ -114,7 +114,6 @@ static const uint8_t mx2PianoKey[77] = · 113 unmodified lines
114114 9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11
115115 };
116116
117−
118117 // thread data
119118 static uint16_t saveInstrNr;
120119 static SDL_Thread *thread;
@@ -438,6 +437,23 @@ static void drawPanning(void) · 317 unmodified lines
438437 hexOutBg(505, 191, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
439438 }
440439
440+void drawC4Rate(void)
441+{
442+ fillRect(465, 299, 71, 8, PAL_DESKTOP);
443+
444+ int32_t C4Hz = 0;
445+ if (editor.curInstr != 0)
446+ {
447+ instrTyp *ins = instr[editor.curInstr];
448+ if (ins != NULL)
449+ C4Hz = (int32_t)(getSampleC4Rate(&ins->samp[editor.curSmp]) + 0.5); // rounded
450+ }
451+
452+ char str[64];
453+ sprintf(str, "%dHz", C4Hz);
454+ textOut(465, 299, PAL_FORGRND, str);
455+}
456+
441457 static void drawFineTune(void)
442458 {
443459 sampleTyp *s;
@@ -505,7 +521,7 @@ static void drawRelTone(void) · 61 unmodified lines
505521
506522 if (instr[editor.curInstr] == NULL)
507523 {
508− fillRect(598, 299, 8*3, 8, PAL_BCKGRND);
524+ fillRect(600, 299, 8*3, 8, PAL_BCKGRND);
509525 return;
510526 }
511527
@@ -528,9 +544,9 @@ static void drawRelTone(void) · 16 unmodified lines
528544
529545 const char octaChar = '0' + (note2 / 12);
530546
531− charOutBg(598, 299, PAL_FORGRND, PAL_BCKGRND, noteChar1);
532− charOutBg(606, 299, PAL_FORGRND, PAL_BCKGRND, noteChar2);
533− charOutBg(614, 299, PAL_FORGRND, PAL_BCKGRND, octaChar);
547+ charOutBg(600, 299, PAL_FORGRND, PAL_BCKGRND, noteChar1);
548+ charOutBg(608, 299, PAL_FORGRND, PAL_BCKGRND, noteChar2);
549+ charOutBg(616, 299, PAL_FORGRND, PAL_BCKGRND, octaChar);
534550 }
535551
536552 static void setStdVolEnvelope(instrTyp *ins, uint8_t num)
@@ -723,6 +739,7 @@ void relToneOctUp(void) · 186 unmodified lines
723739 s->relTon = 71;
724740
725741 drawRelTone();
742+ drawC4Rate();
726743 setSongModifiedFlag();
727744 }
728745
@@ -739,6 +756,7 @@ void relToneOctDown(void) · 10 unmodified lines
739756 s->relTon = -48;
740757
741758 drawRelTone();
759+ drawC4Rate();
742760 setSongModifiedFlag();
743761 }
744762
@@ -753,6 +771,7 @@ void relToneUp(void) · 8 unmodified lines
753771 {
754772 s->relTon++;
755773 drawRelTone();
774+ drawC4Rate();
756775 setSongModifiedFlag();
757776 }
758777 }
@@ -768,6 +787,7 @@ void relToneDown(void) · 9 unmodified lines
768787 {
769788 s->relTon--;
770789 drawRelTone();
790+ drawC4Rate();
771791 setSongModifiedFlag();
772792 }
773793 }
@@ -1283,6 +1303,7 @@ void setFinetuneScroll(uint32_t pos) · 509 unmodified lines
12831303 {
12841304 s->fine = (int8_t)(pos - 128);
12851305 drawFineTune();
1306+ drawC4Rate();
12861307 setSongModifiedFlag();
12871308 }
12881309 }
@@ -1945,55 +1966,6 @@ static void writeEnvelope(int32_t nr) · 656 unmodified lines
19451966 }
19461967 }
19471968
1948−static void textOutTiny(int32_t xPos, int32_t yPos, char *str, uint32_t color)
1949−{
1950− uint32_t *dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
1951− while (*str != '\0')
1952− {
1953− const char chr = *str++;
1954− if (chr < '0' || chr > '9')
1955− {
1956− dstPtr += FONT3_CHAR_W;
1957− continue;
1958− }
1959−
1960− const uint8_t *srcPtr = &bmp.font3[(chr - '0') * FONT3_CHAR_W];
1961− for (int32_t y = 0; y < FONT3_CHAR_H; y++)
1962− {
1963− for (int32_t x = 0; x < FONT3_CHAR_W; x++)
1964− {
1965−#ifdef __arm__
1966− if (srcPtr[x] != 0)
1967− dstPtr[x] = color;
1968−#else
1969− // carefully written like this to generate conditional move instructions (font data is hard to predict)
1970− uint32_t tmp = dstPtr[x];
1971− if (srcPtr[x] != 0) tmp = color;
1972− dstPtr[x] = tmp;
1973−#endif
1974− }
1975−
1976− srcPtr += FONT3_WIDTH;
1977− dstPtr += SCREEN_W;
1978− }
1979−
1980− dstPtr -= (SCREEN_W * FONT3_CHAR_H) - FONT3_CHAR_W;
1981− }
1982−}
1983−
1984−static void textOutTinyOutline(int32_t xPos, int32_t yPos, char *str)
1985−{
1986− const uint32_t bgColor = video.palette[PAL_BCKGRND];
1987− const uint32_t fgColor = video.palette[PAL_FORGRND];
1988−
1989− textOutTiny(xPos-1, yPos, str, bgColor);
1990− textOutTiny(xPos, yPos-1, str, bgColor);
1991− textOutTiny(xPos+1, yPos, str, bgColor);
1992− textOutTiny(xPos, yPos+1, str, bgColor);
1993−
1994− textOutTiny(xPos, yPos, str, fgColor);
1995−}
1996−
19971969 static void drawVolEnvCoords(int16_t tick, int16_t val)
19981970 {
19991971 char str[4];
@@ -2053,7 +2025,7 @@ void handleInstEditorRedrawing(void) · 53 unmodified lines
20532025 tick = 0;
20542026 val = 0;
20552027
2056− if (ins != NULL)
2028+ if (ins != NULL && ins->envVPAnt > 0)
20572029 {
20582030 tick = ins->envVP[editor.currVolEnvPoint][0];
20592031 val = ins->envVP[editor.currVolEnvPoint][1];
@@ -2070,7 +2042,7 @@ void handleInstEditorRedrawing(void) · 10 unmodified lines
20702042 tick = 0;
20712043 val = 32;
20722044
2073− if (ins != NULL)
2045+ if (ins != NULL && ins->envPPAnt > 0)
20742046 {
20752047 tick = ins->envPP[editor.currPanEnvPoint][0];
20762048 val = ins->envPP[editor.currPanEnvPoint][1];
@@ -2201,6 +2173,7 @@ void updateInstEditor(void) · 124 unmodified lines
22012173 drawVibSpeed();
22022174 drawVibDepth();
22032175 drawVibSweep();
2176+ drawC4Rate();
22042177 drawRelTone();
22052178
22062179 // set scroll bars
@@ -2271,7 +2244,7 @@ void showInstEditor(void) · 64 unmodified lines
22712244 drawFramework(2, 188, 337, 70, FRAMEWORK_TYPE2);
22722245 drawFramework(2, 275, 337, 70, FRAMEWORK_TYPE2);
22732246 drawFramework(2, 349, 628, 49, FRAMEWORK_TYPE2);
2274− drawFramework(590, 296, 40, 15, FRAMEWORK_TYPE2);
2247+ drawFramework(593, 296, 36, 15, FRAMEWORK_TYPE2);
22752248
22762249 textOutShadow(20, 176, PAL_FORGRND, PAL_DSKTOP2, "Volume envelope:");
22772250 textOutShadow(153, 176, PAL_FORGRND, PAL_DSKTOP2, "Predef.");
@@ -2294,7 +2267,8 @@ void showInstEditor(void) · 16 unmodified lines
22942267 textOutShadow(442, 236, PAL_FORGRND, PAL_DSKTOP2, "Vib.speed");
22952268 textOutShadow(442, 250, PAL_FORGRND, PAL_DSKTOP2, "Vib.depth");
22962269 textOutShadow(442, 264, PAL_FORGRND, PAL_DSKTOP2, "Vib.sweep");
2297− textOutShadow(453, 299, PAL_FORGRND, PAL_DSKTOP2, "Tone relative to C-4:");
2270+ textOutShadow(442, 299, PAL_FORGRND, PAL_DSKTOP2, "C4=");
2271+ textOutShadow(537, 299, PAL_FORGRND, PAL_DSKTOP2, "Rel. note");
22982272
22992273 showScrollBar(SB_INST_VOL);
23002274 showScrollBar(SB_INST_PAN);
src/ft2_inst_ed.h+2−0
@@ -6,6 +6,8 @@ · 5 unmodified lines
66 #include "ft2_audio.h"
77 #include "ft2_unicode.h"
88
9+void drawC4Rate(void);
10+
911 void saveInstr(UNICHAR *filenameU, int16_t nr);
1012 void loadInstr(UNICHAR *filenameU);
1113 void copyInstr(void); // dstInstr = srcInstr
src/ft2_sample_ed.c+1−5
@@ -460,11 +460,7 @@ void clearCopyBuffer(void) · 459 unmodified lines
460460
461461 int32_t getSampleMiddleCRate(sampleTyp *s)
462462 {
463− const int32_t realFineTune = (int32_t)s->fine >> 3; // the FT2 replayer is ASR'ing the finetune to the right by 3
464− const double dFTune = realFineTune / 16.0; // new range is -16..15
465−
466− const double dFreq = 8363.0 * exp2((s->relTon + dFTune) / 12.0);
467− return (int32_t)(dFreq + 0.5); // rounded
463+ return (int32_t)(getSampleC4Rate(s) + 0.5); // rounded
468464 }
469465
470466 int32_t getSampleRangeStart(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t