sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

synthesis.h (3401B)


      1 #ifndef AUDIO_SYNTHESIS_H
      2 #define AUDIO_SYNTHESIS_H
      3 
      4 #include "internal.h"
      5 
      6 #if defined(VERSION_SH) || defined(VERSION_CN)
      7 #define DEFAULT_LEN_1CH 0x180
      8 #define DEFAULT_LEN_2CH 0x300
      9 #else
     10 #define DEFAULT_LEN_1CH 0x140
     11 #define DEFAULT_LEN_2CH 0x280
     12 #endif
     13 
     14 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
     15 #define MAX_UPDATES_PER_FRAME 5
     16 #else
     17 #define MAX_UPDATES_PER_FRAME 4
     18 #endif
     19 
     20 struct ReverbRingBufferItem {
     21     s16 numSamplesAfterDownsampling;
     22     s16 chunkLen; // never read
     23     s16 *toDownsampleLeft;
     24     s16 *toDownsampleRight; // data pointed to by left and right are adjacent in memory
     25     s32 startPos; // start pos in ring buffer
     26     s16 lengthA; // first length in ring buffer (from startPos, at most until end)
     27     s16 lengthB; // second length in ring buffer (from pos 0)
     28 }; // size = 0x14
     29 
     30 struct SynthesisReverb {
     31     /*0x00, 0x00, 0x00*/ u8 resampleFlags;
     32     /*0x01, 0x01, 0x01*/ u8 useReverb;
     33     /*0x02, 0x02, 0x02*/ u8 framesLeftToIgnore;
     34     /*0x03, 0x03, 0x03*/ u8 curFrame;
     35 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
     36     /*      0x04, 0x04*/ u8 downsampleRate;
     37 #if defined(VERSION_SH) || defined(VERSION_CN)
     38     /*            0x05*/ s8 unk5;
     39 #endif
     40     /*      0x06, 0x06*/ u16 windowSize; // same as bufSizePerChannel
     41 #endif
     42 #if defined(VERSION_SH) || defined(VERSION_CN)
     43     /*            0x08*/ u16 unk08;
     44 #endif
     45     /*0x04, 0x08, 0x0A*/ u16 reverbGain;
     46     /*0x06, 0x0A, 0x0C*/ u16 resampleRate;
     47 #if defined(VERSION_SH) || defined(VERSION_CN)
     48     /*            0x0E*/ u16 panRight;
     49     /*            0x10*/ u16 panLeft;
     50 #endif
     51     /*0x08, 0x0C, 0x14*/ s32 nextRingBufferPos;
     52     /*0x0C, 0x10, 0x18*/ s32 unkC; // never read
     53     /*0x10, 0x14, 0x1C*/ s32 bufSizePerChannel;
     54     struct {
     55         s16 *left;
     56         s16 *right;
     57     } ringBuffer;
     58     /*0x1C, 0x20, 0x28*/ s16 *resampleStateLeft;
     59     /*0x20, 0x24, 0x2C*/ s16 *resampleStateRight;
     60     /*0x24, 0x28, 0x30*/ s16 *unk24; // never read
     61     /*0x28, 0x2C, 0x34*/ s16 *unk28; // never read
     62     /*0x2C, 0x30, 0x38*/ struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME];
     63 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
     64     // Only used in sh:
     65     /*            0x100*/ s16 *unk100;
     66     /*            0x104*/ s16 *unk104;
     67     /*            0x108*/ s16 *unk108;
     68     /*            0x10C*/ s16 *unk10C;
     69 #endif
     70 }; // 0xCC <= size <= 0x100
     71 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
     72 extern struct SynthesisReverb gSynthesisReverbs[4];
     73 extern s8 gNumSynthesisReverbs;
     74 extern struct NoteSubEu *gNoteSubsEu;
     75 extern f32 gLeftVolRampings[3][1024];
     76 extern f32 gRightVolRampings[3][1024];
     77 extern f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above
     78 extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above
     79 #else
     80 extern struct SynthesisReverb gSynthesisReverb;
     81 #endif
     82 
     83 #if defined(VERSION_SH) || defined(VERSION_CN)
     84 extern s16 D_SH_803479B4;
     85 #endif
     86 
     87 u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen);
     88 #if defined(VERSION_JP) || defined(VERSION_US)
     89 void note_init_volume(struct Note *note);
     90 void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverbVol);
     91 void note_set_frequency(struct Note *note, f32 frequency);
     92 void note_enable(struct Note *note);
     93 void note_disable(struct Note *note);
     94 #endif
     95 
     96 #endif // AUDIO_SYNTHESIS_H