ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

ft2_scopes.h (1602B)


      1 #pragma once
      2 
      3 #include <stdint.h>
      4 #include <stdbool.h>
      5 #include "../ft2_header.h"
      6 #include "../ft2_audio.h"
      7 
      8 /* Scopes must be clocked slightly higher than the nominal vblank rate
      9 ** to prevent update/draw racing issues. Setting it too high will
     10 ** cause more issues!
     11 */
     12 #define SCOPE_HZ 64
     13 
     14 #define SCOPE_HEIGHT 36
     15 
     16 #define SCOPE_FRAC_BITS 32
     17 #define SCOPE_FRAC_SCALE ((int64_t)1 << SCOPE_FRAC_BITS)
     18 #define SCOPE_FRAC_MASK (SCOPE_FRAC_SCALE-1)
     19 
     20 #define SCOPE_INTRP_WIDTH 4
     21 #define SCOPE_INTRP_WIDTH_BITS 2 /* log2(SCOPE_INTRP_WIDTH) */
     22 #define SCOPE_INTRP_SCALE 32768
     23 #define SCOPE_INTRP_SCALE_BITS 15 /* log2(SCOPE_INTRP_SCALE) */
     24 #define SCOPE_INTRP_PHASES 512 /* plentiful for FT2-styled scopes */
     25 #define SCOPE_INTRP_PHASES_BITS 9 /* log2(SCOPE_INTRP_PHASES) */
     26 
     27 int32_t getSamplePositionFromScopes(uint8_t ch);
     28 void stopAllScopes(void);
     29 void refreshScopes(void);
     30 bool testScopesMouseDown(void);
     31 void drawScopes(void);
     32 void drawScopeFramework(void);
     33 bool initScopes(void);
     34 
     35 // actual scope data
     36 typedef struct scope_t
     37 {
     38 	volatile bool active;
     39 	const int8_t *base8;
     40 	const int16_t *base16;
     41 	bool wasCleared, sample16Bit, samplingBackwards, hasLooped;
     42 	uint8_t loopType;
     43 	int32_t loopStart, loopLength, loopEnd, sampleEnd, position;
     44 	uint64_t delta, drawDelta, positionFrac;
     45 	float fVolume;
     46 
     47 	// if (loopEnabled && hasLooped && samplingPos <= loopStart+MAX_LEFT_TAPS) readFixedTapsFromThisPointer();
     48 	const int8_t *leftEdgeTaps8;
     49 	const int16_t *leftEdgeTaps16;
     50 } scope_t;
     51 
     52 typedef struct lastChInstr_t
     53 {
     54 	uint8_t smpNum, instrNum;
     55 } lastChInstr_t;
     56 
     57 extern lastChInstr_t lastChInstr[MAX_CHANNELS];