resonance 1.0.1
Loading...
Searching...
No Matches
Harmony Class Reference

The notes of one harmony a track plays from one song position onward. More...

#include <harmony.h>

Public Member Functions

void * operator new (size_t nSize)
 Allocate a harmony from the tagged heap under the tag Harmony.
void operator delete (void *pBlock)
 Release a harmony to the tagged heap.
void AddPitch (unsigned char nNote)
 Insert a note in ascending order, after any equal note.
unsigned char SnapToHarmony (unsigned char nNote) const
 Snap a note to the nearer note of the harmony.
void GetRange (int *pLow, int *pHigh)
 Report the lowest and highest notes.
void Print (std::ostream &stream)
 Write the notes to a diagnostic stream as ( followed by each note and a space, then ).

Public Attributes

std::vector< unsigned char > mNotes

Detailed Description

The notes of one harmony a track plays from one song position onward.

The class emits no RTTI, because it is not polymorphic. Its title is attested by the allocation tag Harmony, under which TrackData allocates it and its deleter releases it. The object is 12 bytes, one vector of one-byte notes kept in ascending order. LevelConverter builds one note at a time through AddPitch() and hands it to TrackData::AddHarmony(), which copies it.

The notes are unsigned. The two binary searches and every reader load them zero-extended and compare them unsigned. Print() alone loads them sign-extended, which is the conversion to char that printing a note performs.

The constructors, the destructor, and the assignment are implicitly declared. The copy constructor is the vector copy constructor instantiation at 0x001d73f8.

Member Function Documentation

◆ operator new()

void * Harmony::operator new ( size_t nSize)
inline

Allocate a harmony from the tagged heap under the tag Harmony.

No out-of-line body exists. TrackData::AddHarmony() expands the call inline.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void Harmony::operator delete ( void * pBlock)
inline

Release a harmony to the tagged heap.

No out-of-line body exists. TrackData's deleter expands the call inline.

Parameters
pBlockThe block.

◆ AddPitch()

void Harmony::AddPitch ( unsigned char nNote)

Insert a note in ascending order, after any equal note.

The position comes from std::upper_bound(), instantiated at 0x001a4f80.

Parameters
nNoteThe note.
Ghidra address:
NTSC-U/C: 0x001a4db0
Ghidra address:
PAL: 0x001aab18

◆ SnapToHarmony()

unsigned char Harmony::SnapToHarmony ( unsigned char nNote) const

Snap a note to the nearer note of the harmony.

The routine finds the first note not below nNote with std::lower_bound(), instantiated at 0x001a4fd0, stepping back one when the search runs off the end, and takes the note below that one as well when one exists. A note above the midpoint of the two resolves to the higher one, and a note at or below it to the lower one.

Parameters
nNoteThe note.
Returns
The nearer note, or nNote when the harmony is empty.
Ghidra address:
NTSC-U/C: 0x001a4e28
Ghidra address:
PAL: 0x001aab90

◆ GetRange()

void Harmony::GetRange ( int * pLow,
int * pHigh )

Report the lowest and highest notes.

The title is inferred.

Parameters
pLowReceives the first note, or 20 when the harmony is empty.
pHighReceives the last note, or 120 when the harmony is empty.
Ghidra address:
NTSC-U/C: 0x001a4eb0
Ghidra address:
PAL: 0x001aac18

◆ Print()

void Harmony::Print ( std::ostream & stream)

Write the notes to a diagnostic stream as ( followed by each note and a space, then ).

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x001a4ee8
Ghidra address:
PAL: 0x001aac50

Member Data Documentation

◆ mNotes

std::vector<unsigned char> Harmony::mNotes

The notes, one byte each, ascending. +0x00


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