yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::app::emu::audio::Dsp Class Reference

#include <dsp.h>

Collaboration diagram for yaze::app::emu::audio::Dsp:

Public Member Functions

 Dsp (std::vector< uint8_t > &aram)
 
void NewFrame ()
 
void Reset ()
 
void Cycle ()
 
void HandleEcho ()
 
void CycleChannel (int ch)
 
void HandleNoise ()
 
void HandleGain (int ch)
 
bool CheckCounter (int rate)
 
void DecodeBrr (int ch)
 
uint8_t Read (uint8_t adr)
 
void Write (uint8_t adr, uint8_t val)
 
int16_t GetSample (int ch)
 
void GetSamples (int16_t *sample_data, int samples_per_frame, bool pal_timing)
 

Private Attributes

int16_t sample_buffer_ [0x400 *2]
 
int16_t sample_offset_
 
std::vector< uint8_t > & aram_
 
uint8_t ram [0x80]
 
DspChannel channel [8]
 
uint16_t counter
 
uint16_t dirPage
 
bool evenCycle
 
bool mute
 
bool reset
 
int8_t masterVolumeL
 
int8_t masterVolumeR
 
int16_t sampleOutL
 
int16_t sampleOutR
 
int16_t echoOutL
 
int16_t echoOutR
 
int16_t noiseSample
 
uint8_t noiseRate
 
bool echoWrites
 
int8_t echoVolumeL
 
int8_t echoVolumeR
 
int8_t feedbackVolume
 
uint16_t echoBufferAdr
 
uint16_t echoDelay
 
uint16_t echoLength
 
uint16_t echoBufferIndex
 
uint8_t firBufferIndex
 
int8_t firValues [8]
 
int16_t firBufferL [8]
 
int16_t firBufferR [8]
 
int16_t sampleBuffer [0x400 *2]
 
uint16_t sampleOffset
 
uint32_t lastFrameBoundary
 

Detailed Description

The S-DSP is a digital signal processor generating the sound data.

A DSP register can be selected with $F2, after which it can be read or written at $F3. Often it is useful to load the register address into A, and the value to send in Y, so that MOV $F2, YA can be used to do both in one 16-bit instruction.

The DSP register address space only has 7 bits. The high bit of $F2, if set, will make the selected register read-only via $F3.

When initializing the DSP registers for the first time, take care not to accidentally enable echo writeback via FLG, because it will immediately begin overwriting values in RAM.

Voices There are 8 voices, numbered 0 to 7. Each voice X has 10 registers in the range $X0-$X9.

| Name | Address | Bits | Notes | |------—|------—|--------—|-----------------------------------------------------—| | VOL (L) | $X0 | SVVV VVVV | Left channel volume, signed. | | VOL (R) | $X1 | SVVV VVVV | Right channel volume, signed. | | P (L) | $X2 | LLLL LLLL | Low 8 bits of sample pitch. | | P (H) | $X3 | –HH HHHH | High 6 bits of sample pitch. | | SCRN | $X4 | SSSS SSSS | Selects a sample source entry from the directory. | | ADSR (1)| $X5 | EDDD AAAA | ADSR enable (E), decay rate (D), attack rate (A). | | ADSR (2)| $X6 | SSSR RRRR | Sustain level (S), release rate (R). | | GAIN | $X7 | 0VVV VVVV 1MMV VVVV | Mode (M), value (V). | | ENVX | $X8 | 0VVV VVVV | Reads current 7-bit value of ADSR/GAIN envelope. | | OUTX | $X9 | SVVV VVVV | Reads signed 8-bit value of current sample wave | | | | | multiplied by ENVX, before applying VOL. |

Definition at line 86 of file dsp.h.

Constructor & Destructor Documentation

◆ Dsp()

yaze::app::emu::audio::Dsp::Dsp ( std::vector< uint8_t > & aram)
inline

Definition at line 88 of file dsp.h.

Member Function Documentation

◆ NewFrame()

void yaze::app::emu::audio::Dsp::NewFrame ( )

Definition at line 132 of file dsp.cc.

References lastFrameBoundary, and sampleOffset.

◆ Reset()

void yaze::app::emu::audio::Dsp::Reset ( )

Definition at line 71 of file dsp.cc.

References yaze::app::emu::audio::DspChannel::adsrState, yaze::app::emu::audio::DspChannel::blockOffset, yaze::app::emu::audio::DspChannel::brrHeader, yaze::app::emu::audio::DspChannel::bufferOffset, channel, counter, yaze::app::emu::audio::DspChannel::decodeOffset, yaze::app::emu::audio::DspChannel::directGain, dirPage, echoBufferAdr, echoBufferIndex, echoDelay, yaze::app::emu::audio::DspChannel::echoEnable, echoLength, echoOutL, echoOutR, echoVolumeL, echoVolumeR, echoWrites, evenCycle, feedbackVolume, firBufferIndex, firBufferL, firBufferR, firValues, yaze::app::emu::audio::DspChannel::gain, yaze::app::emu::audio::DspChannel::gainMode, yaze::app::emu::audio::DspChannel::gainSustainLevel, yaze::app::emu::audio::DspChannel::gainValue, yaze::app::emu::audio::DspChannel::keyOff, yaze::app::emu::audio::DspChannel::keyOn, masterVolumeL, masterVolumeR, mute, noiseRate, noiseSample, yaze::app::emu::audio::DspChannel::pitch, yaze::app::emu::audio::DspChannel::pitchCounter, yaze::app::emu::audio::DspChannel::pitchModulation, yaze::app::emu::audio::DspChannel::preclampGain, ram, reset, sampleBuffer, sampleOffset, yaze::app::emu::audio::DspChannel::sampleOut, sampleOutL, sampleOutR, yaze::app::emu::audio::DspChannel::srcn, yaze::app::emu::audio::DspChannel::startDelay, yaze::app::emu::audio::DspChannel::sustainLevel, yaze::app::emu::audio::DspChannel::useGain, yaze::app::emu::audio::DspChannel::useNoise, yaze::app::emu::audio::DspChannel::volumeL, and yaze::app::emu::audio::DspChannel::volumeR.

Referenced by yaze::app::emu::audio::Apu::Reset().

◆ Cycle()

void yaze::app::emu::audio::Dsp::Cycle ( )

Definition at line 136 of file dsp.cc.

References counter, CycleChannel(), echoOutL, echoOutR, evenCycle, HandleEcho(), HandleNoise(), mute, sampleBuffer, sampleOffset, sampleOutL, and sampleOutR.

Referenced by yaze::app::emu::audio::Apu::Cycle().

Here is the call graph for this function:

◆ HandleEcho()

void yaze::app::emu::audio::Dsp::HandleEcho ( )

◆ CycleChannel()

◆ HandleNoise()

void yaze::app::emu::audio::Dsp::HandleNoise ( )

Definition at line 425 of file dsp.cc.

References CheckCounter(), noiseRate, and noiseSample.

Referenced by Cycle().

Here is the call graph for this function:

◆ HandleGain()

◆ CheckCounter()

bool yaze::app::emu::audio::Dsp::CheckCounter ( int rate)

Definition at line 164 of file dsp.cc.

References counter.

Referenced by HandleGain(), and HandleNoise().

◆ DecodeBrr()

◆ Read()

uint8_t yaze::app::emu::audio::Dsp::Read ( uint8_t adr)

Definition at line 432 of file dsp.cc.

References ram.

Referenced by yaze::app::emu::audio::Apu::Read().

◆ Write()

◆ GetSample()

int16_t yaze::app::emu::audio::Dsp::GetSample ( int ch)

◆ GetSamples()

void yaze::app::emu::audio::Dsp::GetSamples ( int16_t * sample_data,
int samples_per_frame,
bool pal_timing )

Definition at line 621 of file dsp.cc.

References lastFrameBoundary, and sample_buffer_.

Member Data Documentation

◆ sample_buffer_

int16_t yaze::app::emu::audio::Dsp::sample_buffer_[0x400 *2]
private

Definition at line 114 of file dsp.h.

Referenced by GetSamples().

◆ sample_offset_

int16_t yaze::app::emu::audio::Dsp::sample_offset_
private

Definition at line 115 of file dsp.h.

◆ aram_

std::vector<uint8_t>& yaze::app::emu::audio::Dsp::aram_
private

Definition at line 117 of file dsp.h.

Referenced by CycleChannel(), DecodeBrr(), and HandleEcho().

◆ ram

uint8_t yaze::app::emu::audio::Dsp::ram[0x80]
private

Definition at line 120 of file dsp.h.

Referenced by CycleChannel(), Read(), Reset(), and Write().

◆ channel

DspChannel yaze::app::emu::audio::Dsp::channel[8]
private

Definition at line 122 of file dsp.h.

Referenced by CycleChannel(), DecodeBrr(), GetSample(), HandleGain(), Reset(), and Write().

◆ counter

uint16_t yaze::app::emu::audio::Dsp::counter
private

Definition at line 124 of file dsp.h.

Referenced by CheckCounter(), Cycle(), and Reset().

◆ dirPage

uint16_t yaze::app::emu::audio::Dsp::dirPage
private

Definition at line 125 of file dsp.h.

Referenced by CycleChannel(), Reset(), and Write().

◆ evenCycle

bool yaze::app::emu::audio::Dsp::evenCycle
private

Definition at line 126 of file dsp.h.

Referenced by Cycle(), CycleChannel(), and Reset().

◆ mute

bool yaze::app::emu::audio::Dsp::mute
private

Definition at line 127 of file dsp.h.

Referenced by Cycle(), Reset(), and Write().

◆ reset

bool yaze::app::emu::audio::Dsp::reset
private

Definition at line 128 of file dsp.h.

Referenced by CycleChannel(), Reset(), and Write().

◆ masterVolumeL

int8_t yaze::app::emu::audio::Dsp::masterVolumeL
private

Definition at line 129 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ masterVolumeR

int8_t yaze::app::emu::audio::Dsp::masterVolumeR
private

Definition at line 130 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ sampleOutL

int16_t yaze::app::emu::audio::Dsp::sampleOutL
private

Definition at line 132 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), and Reset().

◆ sampleOutR

int16_t yaze::app::emu::audio::Dsp::sampleOutR
private

Definition at line 133 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), and Reset().

◆ echoOutL

int16_t yaze::app::emu::audio::Dsp::echoOutL
private

Definition at line 134 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), and Reset().

◆ echoOutR

int16_t yaze::app::emu::audio::Dsp::echoOutR
private

Definition at line 135 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), and Reset().

◆ noiseSample

int16_t yaze::app::emu::audio::Dsp::noiseSample
private

Definition at line 137 of file dsp.h.

Referenced by CycleChannel(), HandleNoise(), and Reset().

◆ noiseRate

uint8_t yaze::app::emu::audio::Dsp::noiseRate
private

Definition at line 138 of file dsp.h.

Referenced by HandleNoise(), Reset(), and Write().

◆ echoWrites

bool yaze::app::emu::audio::Dsp::echoWrites
private

Definition at line 140 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ echoVolumeL

int8_t yaze::app::emu::audio::Dsp::echoVolumeL
private

Definition at line 141 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ echoVolumeR

int8_t yaze::app::emu::audio::Dsp::echoVolumeR
private

Definition at line 142 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ feedbackVolume

int8_t yaze::app::emu::audio::Dsp::feedbackVolume
private

Definition at line 143 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ echoBufferAdr

uint16_t yaze::app::emu::audio::Dsp::echoBufferAdr
private

Definition at line 144 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ echoDelay

uint16_t yaze::app::emu::audio::Dsp::echoDelay
private

Definition at line 145 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ echoLength

uint16_t yaze::app::emu::audio::Dsp::echoLength
private

Definition at line 146 of file dsp.h.

Referenced by HandleEcho(), and Reset().

◆ echoBufferIndex

uint16_t yaze::app::emu::audio::Dsp::echoBufferIndex
private

Definition at line 147 of file dsp.h.

Referenced by HandleEcho(), and Reset().

◆ firBufferIndex

uint8_t yaze::app::emu::audio::Dsp::firBufferIndex
private

Definition at line 148 of file dsp.h.

Referenced by HandleEcho(), and Reset().

◆ firValues

int8_t yaze::app::emu::audio::Dsp::firValues[8]
private

Definition at line 149 of file dsp.h.

Referenced by HandleEcho(), Reset(), and Write().

◆ firBufferL

int16_t yaze::app::emu::audio::Dsp::firBufferL[8]
private

Definition at line 150 of file dsp.h.

Referenced by HandleEcho(), and Reset().

◆ firBufferR

int16_t yaze::app::emu::audio::Dsp::firBufferR[8]
private

Definition at line 151 of file dsp.h.

Referenced by HandleEcho(), and Reset().

◆ sampleBuffer

int16_t yaze::app::emu::audio::Dsp::sampleBuffer[0x400 *2]
private

Definition at line 153 of file dsp.h.

Referenced by Cycle(), and Reset().

◆ sampleOffset

uint16_t yaze::app::emu::audio::Dsp::sampleOffset
private

Definition at line 154 of file dsp.h.

Referenced by Cycle(), NewFrame(), and Reset().

◆ lastFrameBoundary

uint32_t yaze::app::emu::audio::Dsp::lastFrameBoundary
private

Definition at line 155 of file dsp.h.

Referenced by GetSamples(), and NewFrame().


The documentation for this class was generated from the following files: