-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65, Version
v3.4.0-alpha
from sam-astro/dev
Begin merging dev branch with main, `v3.4.0-alpha` update
- Loading branch information
Showing
78 changed files
with
536,497 additions
and
785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-87.2 KB
...-Emulator/.vs/Astro8-Emulator/FileContentIndex/93a690a8-3cf3-47fc-95dd-307b7004d298.vsidx
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+1.71 MB
(100%)
Astro8-Emulator/.vs/Astro8-Emulator/v17/Preview/Browse.VC.db
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#pragma once | ||
|
||
namespace VSSynth | ||
{ | ||
/** | ||
* @brief Collection of sound generators provided with VSSynth | ||
*/ | ||
namespace Generators | ||
{ | ||
} | ||
|
||
/** | ||
* @brief Sound generating device | ||
* | ||
* A sound generator is responsible for creating the sound output which will be eventually sent to the speaker. | ||
* Sound generators can be simple waveforms, a modulated waveform from an ADSR envelope, or it can playback PCM audio from a file. | ||
*/ | ||
class SoundGenerator | ||
{ | ||
public: | ||
SoundGenerator(); | ||
virtual ~SoundGenerator(); | ||
|
||
/** | ||
* @brief Sample the SoundGenerator at the given time | ||
* | ||
* This is the main interaction between the Synthesizer and the SoundGenerator. This method will be called at the rate of the sampling rate specified by the Synthesizer's constructor. | ||
* | ||
* @warning Since this function is called so frequently you should make computations as fast and efficient as possible. | ||
* Needless to say, do not block the running thread when implementing this function. | ||
* | ||
* @param time - in seconds | ||
* @return double - sound sample in range [-1.0,1.0] | ||
* | ||
* @see Synthesizer | ||
*/ | ||
virtual double sample(double time) = 0; | ||
|
||
/** | ||
* @brief Sets the volume at a certain percent | ||
* | ||
* @param percent - volume as a percent in range [0,100] | ||
*/ | ||
void setVolume(double percent); | ||
|
||
/** | ||
* @brief Gets the current volume as a percent | ||
* | ||
* @return double - volume as a percent [0, 100] | ||
*/ | ||
double getVolume(); | ||
|
||
/** | ||
* @brief Amplitude for synthesizer | ||
* | ||
* Sound generators, when sampled, return a value in [-1.0, 1.0]. | ||
* This value will be multiplied by the amplitude returned by this | ||
* function. The amplitude will be a value such that it can fit | ||
* in a 16-bit signed integer. | ||
* | ||
* This function is mainly for the Synthesizer. You shouldn't | ||
* really have a reason to call this function. | ||
* | ||
* @see Synthesizer | ||
* @return double | ||
*/ | ||
double getAmplitude(); | ||
|
||
protected: | ||
double mAmplitude; | ||
}; | ||
} // namespace VSSynth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
namespace VSSynth | ||
{ | ||
/** | ||
* @brief Collection of middleware for use with the synthesizer | ||
*/ | ||
namespace Middleware | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @brief Read and modify samples prior to sending them to the speaker | ||
* | ||
* Middleware has the ability to modify any samples prior to sending it to the speaker. | ||
* This can allow for the creation of filters, sample analyzers or audio file writers. | ||
* | ||
* @see Synthesizer | ||
*/ | ||
class SynthMiddleware | ||
{ | ||
public: | ||
/** | ||
* @brief Process the current sample and output the modified sample | ||
* @param currentSample | ||
* @param time | ||
* @return short | ||
*/ | ||
virtual short processSample(short currentSample, double time) = 0; | ||
}; | ||
} // namespace VSSynth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
|
||
#include <SDL.h> | ||
|
||
#include <functional> | ||
#include <vector> | ||
|
||
#include "SoundGenerator.h" | ||
#include "SynthMiddleware.h" | ||
|
||
namespace VSSynth | ||
{ | ||
struct SynthData | ||
{ | ||
double *time; | ||
double sampleDeltaTime; | ||
std::vector<SoundGenerator *> soundGenerators; | ||
std::vector<SynthMiddleware *> middleware; | ||
}; | ||
|
||
/** | ||
* @brief Entrypoint and interface for audio synthesis | ||
* | ||
* The synthesizer is the main building block of the VSSynth audio synthesizer. | ||
* This synthesizer uses additive synthesis to create sound. | ||
* | ||
* SoundGenerators are responsible for creating the sounds and must be added to this synth. | ||
* | ||
* Middleware can be added to read and/or modify the sound output prior to reaching the speaker. | ||
* | ||
* @see SoundGenerator | ||
* @see Middleware | ||
*/ | ||
class Synthesizer | ||
{ | ||
public: | ||
/** | ||
* @brief Create a new Synthesizer | ||
* | ||
* @param samplingRates - Sampling rate (# of samples per second). | ||
* Higher values are computationally intensive while lower values have a limit scope of sound frequencies. | ||
* @param numFrames - Number of sampling frames. A sampling frame is an instance where sound generators are sampled. | ||
*/ | ||
Synthesizer(unsigned int samplingRates = 48000, unsigned int numFrames = 20); | ||
virtual ~Synthesizer(); | ||
|
||
/** | ||
* @brief Creates the internal audio device (SDL should be initialized prior to calling this) | ||
* | ||
* @warning SDL AUDIO must be initialized prior to calling open() | ||
*/ | ||
void open(); | ||
|
||
/** | ||
* @brief Destroys the internal audio device | ||
* | ||
*/ | ||
void close(); | ||
|
||
/** | ||
* @brief Pauses the synthesizer | ||
* | ||
* Sound will stop if the synthesizer is currently running | ||
*/ | ||
void pause(); | ||
|
||
/** | ||
* @brief Unpauses the synthesizer | ||
* | ||
* Sound will resume if the synthesizer has been paused | ||
*/ | ||
void unpause(); | ||
|
||
/** | ||
* @brief Adds a sound generator to the synthesizer | ||
* | ||
* @param soundGenerator | ||
*/ | ||
void addSoundGenerator(SoundGenerator *soundGenerator); | ||
|
||
/** | ||
* @brief Adds a middleware to the synthesizer | ||
* | ||
* @param middleware | ||
*/ | ||
void addMiddleware(SynthMiddleware *middleware); | ||
|
||
private: | ||
SDL_AudioDeviceID mDeviceID; | ||
|
||
double mTime; | ||
|
||
unsigned int mSamplingRate; | ||
unsigned int mNumFrames; | ||
|
||
SynthData mSynthData; | ||
}; | ||
|
||
}; // namespace VSSynth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include "SoundGenerator.h" | ||
#include "SynthMiddleware.h" | ||
#include "Synthesizer.h" | ||
#include "generators/Instrument.h" | ||
#include "generators/MonophonicInstrument.h" | ||
#include "generators/PolyphonicInstrument.h" | ||
#include "generators/Sequencer.h" | ||
#include "generators/Tone.h" | ||
#include "middleware/WAVWriter.h" | ||
#include "utils/Envelope.h" | ||
#include "utils/Notes.h" | ||
#include "utils/Patches.h" | ||
#include "utils/Waveforms.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
|
||
#include "../utils/Envelope.h" | ||
#include "../SoundGenerator.h" | ||
|
||
namespace VSSynth | ||
{ | ||
namespace Generators | ||
{ | ||
/** | ||
* @brief Device capable of playing multiple notes with an ADSR envelope | ||
*/ | ||
class Instrument : public SoundGenerator | ||
{ | ||
public: | ||
Instrument(std::function<double(double, double)> wave); | ||
|
||
virtual ~Instrument(); | ||
|
||
/** | ||
* @brief Samples the instrument at the given time | ||
* | ||
* @param time | ||
* @return double | ||
*/ | ||
virtual double sample(double time) = 0; | ||
|
||
/** | ||
* @brief Holds the given note | ||
* | ||
* @param frequency - the note | ||
*/ | ||
virtual void holdNote(double frequency) = 0; | ||
/** | ||
* @brief Releases the given note | ||
* | ||
* @param frequency - the note | ||
*/ | ||
virtual void releaseNote(double frequency) = 0; | ||
|
||
protected: | ||
std::function<double(double, double)> mWave; | ||
}; | ||
} // namespace Generators | ||
} // namespace VSSynth |
Oops, something went wrong.