ComSquare
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ComSquare::APU::DSP::DSP Class Reference

#include <DSP.hpp>

Collaboration diagram for ComSquare::APU::DSP::DSP:

Public Member Functions

 DSP (Renderer::IRenderer &renderer, MemoryMap &map)
 
 DSP (const DSP &)=default
 
DSPoperator= (const DSP &)=delete
 
 ~DSP ()=default
 
const std::array< Voice, 8 > & getVoices () const
 Return all 8 voices from DSP. More...
 
const MastergetMaster () const
 
const EchogetEcho () const
 
const NoisegetNoise () const
 
const BRRgetBrr () const
 
const LatchgetLatch () const
 
uint8_t read (uint24_t addr) const
 Read from the internal DSP register. More...
 
void write (uint24_t addr, uint8_t data)
 Write data to the internal DSP register. More...
 
std::string getName () const
 Get the name of this accessor (used for debug purpose) More...
 
void update ()
 Execute current voice transformation. More...
 
Component getComponent () const
 Get the component of this accessor (used for debug purpose) More...
 
uint24_t getSize () const
 Get the size of the data. This size can be lower than the mapped data. More...
 
int32_t getSamplesCount () const
 Return the number of samples written. More...
 

Private Member Functions

void voiceOutput (Voice &voice, bool channel)
 
void voice1 (Voice &voice)
 
void voice2 (Voice &voice)
 
void voice3 (Voice &voice)
 
void voice3a (Voice &voice)
 
void voice3b (Voice &voice)
 
void voice3c (Voice &voice)
 
void voice4 (Voice &voice)
 
void voice5 (Voice &voice)
 
void voice6 (Voice &voice)
 
void voice7 (Voice &voice)
 
void voice8 (Voice &voice)
 
void voice9 (Voice &voice)
 
void echo22 ()
 
void echo23 ()
 
void echo24 ()
 
void echo25 ()
 
void echo26 ()
 
void echo27 ()
 
void echo28 ()
 
void echo29 ()
 
void echo30 ()
 
void misc27 ()
 
void misc28 ()
 
void misc29 ()
 
void misc30 ()
 
int32_t interpolate (const Voice &voice)
 Interpolate voice samples with gauss table. More...
 
void runEnvelope (Voice &voice)
 Modify voice samples with its envelope. More...
 
int32_t loadFIR (bool channel, int fir)
 
void loadEcho (bool channel)
 
int16_t outputEcho (bool channel)
 
void writeEcho (bool channel)
 
void timerTick ()
 Remove one tick from timer. More...
 
bool timerPoll (uint32_t rate)
 Check if timer value is equal to rate value. More...
 
void decodeBRR (Voice &voice)
 Transform BRR value to samples. More...
 
uint8_t _readRAM (uint24_t addr)
 Read inside APU RAM. More...
 
void _writeRAM (uint24_t addr, uint8_t data)
 Write into APU RAM. More...
 

Private Attributes

std::array< uint16_t, 32 > _rateModulus
 Number of samples per counter event. More...
 
std::array< uint16_t, 32 > _counterOffset
 Counter offset. More...
 
std::array< int16_t, 512 > _gauss
 Gaussian table used for making waves. More...
 
std::array< int16_t, 0x10000 > _soundBuffer = {}
 Buffer containing samples to be played. More...
 
std::array< Voice, 8 > _voices {}
 8x voices of sample used to make sound More...
 
Master _master {}
 
Echo _echo {}
 
Noise _noise {}
 
BRR _brr {}
 
Latch _latch {}
 
State _state
 
Timer _timer {}
 
MemoryMap_map
 Whole APU RAM map. More...
 
Renderer::IRenderer_renderer
 Renderer used to play sounds. More...
 

Constructor & Destructor Documentation

◆ DSP() [1/2]

ComSquare::APU::DSP::DSP::DSP ( Renderer::IRenderer renderer,
MemoryMap map 
)

◆ DSP() [2/2]

ComSquare::APU::DSP::DSP::DSP ( const DSP )
default

◆ ~DSP()

ComSquare::APU::DSP::DSP::~DSP ( )
default

Member Function Documentation

◆ _readRAM()

uint8_t ComSquare::APU::DSP::DSP::_readRAM ( uint24_t  addr)
private

Read inside APU RAM.

◆ _writeRAM()

void ComSquare::APU::DSP::DSP::_writeRAM ( uint24_t  addr,
uint8_t  data 
)
private

Write into APU RAM.

◆ decodeBRR()

void ComSquare::APU::DSP::DSP::decodeBRR ( Voice voice)
private

Transform BRR value to samples.

◆ echo22()

void ComSquare::APU::DSP::DSP::echo22 ( )
private

◆ echo23()

void ComSquare::APU::DSP::DSP::echo23 ( )
private

◆ echo24()

void ComSquare::APU::DSP::DSP::echo24 ( )
private

◆ echo25()

void ComSquare::APU::DSP::DSP::echo25 ( )
private

◆ echo26()

void ComSquare::APU::DSP::DSP::echo26 ( )
private

◆ echo27()

void ComSquare::APU::DSP::DSP::echo27 ( )
private

◆ echo28()

void ComSquare::APU::DSP::DSP::echo28 ( )
private

◆ echo29()

void ComSquare::APU::DSP::DSP::echo29 ( )
private

◆ echo30()

void ComSquare::APU::DSP::DSP::echo30 ( )
private

◆ getBrr()

const BRR & ComSquare::APU::DSP::DSP::getBrr ( ) const

◆ getComponent()

Component ComSquare::APU::DSP::DSP::getComponent ( ) const

Get the component of this accessor (used for debug purpose)

◆ getEcho()

const Echo & ComSquare::APU::DSP::DSP::getEcho ( ) const

◆ getLatch()

const Latch & ComSquare::APU::DSP::DSP::getLatch ( ) const

◆ getMaster()

const Master & ComSquare::APU::DSP::DSP::getMaster ( ) const

◆ getName()

std::string ComSquare::APU::DSP::DSP::getName ( ) const

Get the name of this accessor (used for debug purpose)

◆ getNoise()

const Noise & ComSquare::APU::DSP::DSP::getNoise ( ) const

◆ getSamplesCount()

int32_t ComSquare::APU::DSP::DSP::getSamplesCount ( ) const

Return the number of samples written.

◆ getSize()

uint24_t ComSquare::APU::DSP::DSP::getSize ( ) const

Get the size of the data. This size can be lower than the mapped data.

Returns
The number of bytes inside this memory.

◆ getVoices()

const std::array< Voice, 8 > & ComSquare::APU::DSP::DSP::getVoices ( ) const

Return all 8 voices from DSP.

◆ interpolate()

int32_t ComSquare::APU::DSP::DSP::interpolate ( const Voice voice)
private

Interpolate voice samples with gauss table.

◆ loadEcho()

void ComSquare::APU::DSP::DSP::loadEcho ( bool  channel)
private

◆ loadFIR()

int32_t ComSquare::APU::DSP::DSP::loadFIR ( bool  channel,
int  fir 
)
private

◆ misc27()

void ComSquare::APU::DSP::DSP::misc27 ( )
private

◆ misc28()

void ComSquare::APU::DSP::DSP::misc28 ( )
private

◆ misc29()

void ComSquare::APU::DSP::DSP::misc29 ( )
private

◆ misc30()

void ComSquare::APU::DSP::DSP::misc30 ( )
private

◆ operator=()

DSP& ComSquare::APU::DSP::DSP::operator= ( const DSP )
delete

◆ outputEcho()

int16_t ComSquare::APU::DSP::DSP::outputEcho ( bool  channel)
private

◆ read()

uint8_t ComSquare::APU::DSP::DSP::read ( uint24_t  addr) const

Read from the internal DSP register.

Parameters
addrThe address to read from. The address 0x0 should refer to the first byte of the register.
Exceptions
InvalidAddresswill be thrown if the address is more than $7F (the number of register).
Returns
Return the value of the register.

◆ runEnvelope()

void ComSquare::APU::DSP::DSP::runEnvelope ( Voice voice)
private

Modify voice samples with its envelope.

◆ timerPoll()

bool ComSquare::APU::DSP::DSP::timerPoll ( uint32_t  rate)
private

Check if timer value is equal to rate value.

◆ timerTick()

void ComSquare::APU::DSP::DSP::timerTick ( )
private

Remove one tick from timer.

◆ update()

void ComSquare::APU::DSP::DSP::update ( )

Execute current voice transformation.

◆ voice1()

void ComSquare::APU::DSP::DSP::voice1 ( Voice voice)
private

◆ voice2()

void ComSquare::APU::DSP::DSP::voice2 ( Voice voice)
private

◆ voice3()

void ComSquare::APU::DSP::DSP::voice3 ( Voice voice)
private

◆ voice3a()

void ComSquare::APU::DSP::DSP::voice3a ( Voice voice)
private

◆ voice3b()

void ComSquare::APU::DSP::DSP::voice3b ( Voice voice)
private

◆ voice3c()

void ComSquare::APU::DSP::DSP::voice3c ( Voice voice)
private

◆ voice4()

void ComSquare::APU::DSP::DSP::voice4 ( Voice voice)
private

◆ voice5()

void ComSquare::APU::DSP::DSP::voice5 ( Voice voice)
private

◆ voice6()

void ComSquare::APU::DSP::DSP::voice6 ( Voice voice)
private

◆ voice7()

void ComSquare::APU::DSP::DSP::voice7 ( Voice voice)
private

◆ voice8()

void ComSquare::APU::DSP::DSP::voice8 ( Voice voice)
private

◆ voice9()

void ComSquare::APU::DSP::DSP::voice9 ( Voice voice)
private

◆ voiceOutput()

void ComSquare::APU::DSP::DSP::voiceOutput ( Voice voice,
bool  channel 
)
private

◆ write()

void ComSquare::APU::DSP::DSP::write ( uint24_t  addr,
uint8_t  data 
)

Write data to the internal DSP register.

Parameters
addrThe address to write to. The address 0x0 should refer to the first byte of register.
dataThe new value of the register.
Exceptions
InvalidAddresswill be thrown if the address is more than $7F (the number of register).

◆ writeEcho()

void ComSquare::APU::DSP::DSP::writeEcho ( bool  channel)
private

Member Data Documentation

◆ _brr

BRR ComSquare::APU::DSP::DSP::_brr {}
private

◆ _counterOffset

std::array<uint16_t, 32> ComSquare::APU::DSP::DSP::_counterOffset
private
Initial value:
= {
0, 0, 1040, 536, 0, 1040,
536, 0, 1040, 536, 0, 1040,
536, 0, 1040, 536, 0, 1040,
536, 0, 1040, 536, 0, 1040,
536, 0, 1040, 536, 0, 1040,
0,0
}

Counter offset.

◆ _echo

Echo ComSquare::APU::DSP::DSP::_echo {}
private

◆ _gauss

std::array<int16_t, 512> ComSquare::APU::DSP::DSP::_gauss
private

Gaussian table used for making waves.

◆ _latch

Latch ComSquare::APU::DSP::DSP::_latch {}
private

◆ _map

MemoryMap& ComSquare::APU::DSP::DSP::_map
private

Whole APU RAM map.

◆ _master

Master ComSquare::APU::DSP::DSP::_master {}
private

◆ _noise

Noise ComSquare::APU::DSP::DSP::_noise {}
private

◆ _rateModulus

std::array<uint16_t, 32> ComSquare::APU::DSP::DSP::_rateModulus
private
Initial value:
= {
0, 2048, 1536, 1280, 1024, 768,
640, 512, 384, 320, 256, 192,
160, 128, 96, 80, 64, 48,
40, 32, 24, 20, 16, 12,
10, 8, 6, 5, 4, 3,
2, 1
}

Number of samples per counter event.

◆ _renderer

Renderer::IRenderer& ComSquare::APU::DSP::DSP::_renderer
private

Renderer used to play sounds.

◆ _soundBuffer

std::array<int16_t, 0x10000> ComSquare::APU::DSP::DSP::_soundBuffer = {}
private

Buffer containing samples to be played.

◆ _state

State ComSquare::APU::DSP::DSP::_state
private

◆ _timer

Timer ComSquare::APU::DSP::DSP::_timer {}
private

◆ _voices

std::array<Voice, 8> ComSquare::APU::DSP::DSP::_voices {}
private

8x voices of sample used to make sound


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