summaryrefslogtreecommitdiff
path: root/src/audio/effects.h
blob: 8c771282590ddfdb26b785c1d6f0d182f69d37f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef AUDIO_EFFECTS_H
#define AUDIO_EFFECTS_H

#include "audio/internal.h"

#ifdef TARGET_N64
#define IS_BIG_ENDIAN 1
#endif

#define ADSR_STATE_DISABLED 0
#define ADSR_STATE_INITIAL 1
#define ADSR_STATE_START_LOOP 2
#define ADSR_STATE_LOOP 3
#define ADSR_STATE_FADE 4
#define ADSR_STATE_HANG 5
#define ADSR_STATE_DECAY 6
#define ADSR_STATE_RELEASE 7
#define ADSR_STATE_SUSTAIN 8

#define ADSR_ACTION_RELEASE 0x10
#define ADSR_ACTION_DECAY 0x20
#define ADSR_ACTION_HANG 0x40

#define ADSR_DISABLE 0
#define ADSR_HANG -1
#define ADSR_GOTO -2
#define ADSR_RESTART -3

// Envelopes are always stored as big endian, to match sequence files which are
// byte blobs and can embed envelopes. Hence this byteswapping macro.
#if IS_BIG_ENDIAN
#define BSWAP16(x) (x)
#else
#define BSWAP16(x) (((x) & 0xff) << 8 | (((x) >> 8) & 0xff))
#endif

void sequence_channel_process_sound(struct SequenceChannel* seqChannel, s32 recalculateVolume);
void sequence_player_process_sound(struct SequencePlayer* seqPlayer);
f32 get_portamento_freq_scale(struct Portamento* p);
s16 get_vibrato_pitch_change(struct VibratoState* vib);
f32 get_vibrato_freq_scale(struct VibratoState* vib);
void note_vibrato_update(struct Note* note);
void note_vibrato_init(struct Note* note);
void adsr_init(struct AdsrState* adsr, struct AdsrEnvelope* envelope, s16* volOut);
f32 adsr_update(struct AdsrState* adsr);

#endif /* AUDIO_EFFECTS_H */