MD_YM2413 Library  1.0
Library for Yahama YM2413 sound synthesizer
YM2413Emulator Class Reference

YM2413 emulator which provdes the methods from the emulator and which implements an Arduino Stream so that the generated sound can be read via readBytes(). More...

#include <YM2413Emulator.h>

Inheritance diagram for YM2413Emulator:
Collaboration diagram for YM2413Emulator:

Public Member Functions

 YM2413Emulator (uint32_t sampleRate=SAMPLERATE, uint64_t clock=MSX_CLK)
 
void begin ()
 
void send (uint8_t addr, uint8_t data)
 
uint8_t channels ()
 
uint32_t bitsPerSample ()
 Bits per sample of audio result.
 
uint32_t sampleRate ()
 Sample Rate audo audio output result.
 
void reset ()
 
void resetPatch (uint8_t p)
 
void setSampleRate (uint32_t rate)
 
void setQuality (uint8_t q)
 
void setPan (uint32_t ch, uint8_t pan)
 
void setPanFine (uint32_t ch, float pan[2])
 
void setChipType (uint8_t type)
 
void writeIO (uint32_t reg, uint8_t val)
 
void writeReg (uint32_t reg, uint8_t val)
 
void setPatch (const uint8_t *dump)
 
void forceRefresh ()
 
uint32_t setMask (uint32_t mask)
 
uint32_t toggleMask (uint32_t mask)
 
int16_t getSampleMono ()
 Calculates the next mono sample. More...
 
void getSamplesStereo (int32_t *out)
 Calculates the next stereo samples () More...
 
OPLL * opll ()
 Provides a pointer to the OPLL object.
 
void setBoost (uint8_t multiplier)
 The default volume might be too low, we allow to boost the volume by a defined factor. More...
 
int available ()
 
size_t readBytes (uint8_t *buffer, size_t len)
 
bool hasSound ()
 
int availableForWrite ()
 Write is not supported!
 
size_t write (uint8_t)
 Write is not supported!
 
int read ()
 Read of single bytes is not supported!
 
int peek ()
 Read of single bytes is not supported!
 
- Public Member Functions inherited from MD_IODriver
 MD_IODriver (const pin_t *D, pin_t we, pin_t a0)
 

Static Public Member Functions

static void dumpToPatch (const uint8_t *dump, OPLL_PATCH *patch)
 
static void patchToDump (const OPLL_PATCH *patch, uint8_t *dump)
 
static void getDefaultPatch (int32_t type, int32_t num, OPLL_PATCH *patch)
 

Protected Types

enum  Functions {
  D0 =0 , D1 , D2 , D3 ,
  P4 , D5 , D7 , WE ,
  A0
}
 

Protected Attributes

const char * pinNames [9] = {"D0","D1","D2","D3","P4","D5","D7","WE","A0"}
 
uint8_t values [9]
 
OPLL * p_opll = nullptr
 
uint8_t address = 0
 
uint32_t sample_rate =0
 
uint64_t clock = 0
 
uint8_t boost = 7
 
bool has_sound = false
 

Friends

class MD_YM2413
 

Additional Inherited Members

- Public Attributes inherited from MD_IODriver
pin_t * D = nullptr
 
pin_t we
 
pin_t a0
 

Detailed Description

YM2413 emulator which provdes the methods from the emulator and which implements an Arduino Stream so that the generated sound can be read via readBytes().

It implements the MD_IODriver interface, so that it can be passed as argument to the constructor of MD_YM2413 API class.

Member Function Documentation

◆ forceRefresh()

void YM2413Emulator::forceRefresh ( )

Force to refresh. External program should call this function after updating patch parameters.

◆ getSampleMono()

int16_t YM2413Emulator::getSampleMono ( )

Calculates the next mono sample.

Returns
int16_t

◆ getSamplesStereo()

void YM2413Emulator::getSamplesStereo ( int32_t *  out)

Calculates the next stereo samples ()

Parameters
out

◆ readBytes()

size_t YM2413Emulator::readBytes ( uint8_t *  buffer,
size_t  len 
)

Returns the audio data as byte stream

◆ setBoost()

void YM2413Emulator::setBoost ( uint8_t  multiplier)

The default volume might be too low, we allow to boost the volume by a defined factor.

Parameters
multiplier

◆ setChipType()

void YM2413Emulator::setChipType ( uint8_t  type)

Set chip type. If vrc7 is selected, r#14 is ignored. This method not change the current ROM patch set. To change ROM patch set, use OPLL_resetPatch.

Parameters
type0:YM2413 1:VRC7

◆ setMask()

uint32_t YM2413Emulator::setMask ( uint32_t  mask)

Set channel mask

Parameters
maskmask flag: OPLL_MASK_* can be used.
  • bit 0..8: mask for ch 1 to 9 (OPLL_MASK_CH(i))
  • bit 9: mask for Hi-Hat (OPLL_MASK_HH)
  • bit 10: mask for Top-Cym (OPLL_MASK_CYM)
  • bit 11: mask for Tom (OPLL_MASK_TOM)
  • bit 12: mask for Snare Drum (OPLL_MASK_SD)
  • bit 13: mask for Bass Drum (OPLL_MASK_BD)

◆ setPan()

void YM2413Emulator::setPan ( uint32_t  ch,
uint8_t  pan 
)

Set pan pot (extra function - not YM2413 chip feature)

Parameters
ch0..8:tone 9:bd 10:hh 11:sd 12:tom 13:cym 14,15:reserved
pan0:mute 1:right 2:left 3:center
pan: 76543210
|+- bit 1: enable Left output
+-- bit 0: enable Right output

◆ setPanFine()

void YM2413Emulator::setPanFine ( uint32_t  ch,
float  pan[2] 
)

Set fine-grained panning

Parameters
ch0..8:tone 9:bd 10:hh 11:sd 12:tom 13:cym 14,15:reserved
panoutput strength of left/right channel. pan[0]: left, pan[1]: right. pan[0]=pan[1]=1.0f for center.

◆ setPatch()

void YM2413Emulator::setPatch ( const uint8_t *  dump)

Defines the actual patch

◆ setQuality()

void YM2413Emulator::setQuality ( uint8_t  q)

Set internal calcuration quality. Currently no effects, just for compatibility. >= v1.0.0 always synthesizes internal output at clock/72 Hz.

◆ setSampleRate()

void YM2413Emulator::setSampleRate ( uint32_t  rate)

Set output wave sampling rate.

Parameters
ratesampling rate. If clock / 72 (typically 49716 or 49715 at 3.58MHz) is set, the internal rate converter is disabled.

◆ toggleMask()

uint32_t YM2413Emulator::toggleMask ( uint32_t  mask)

Toggler channel mask flag

◆ writeIO()

void YM2413Emulator::writeIO ( uint32_t  reg,
uint8_t  val 
)

Writes a register or value

◆ writeReg()

void YM2413Emulator::writeReg ( uint32_t  reg,
uint8_t  val 
)

Updates a register with the indicated value


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