| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Player structure |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -59,6 +59,35 @@ void Player::ClearState() |
| 59 | 59 |
this->masterVol = 0; // this is actually the highest level |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
+void Player::FreeTracks() |
|
| 63 |
+{
|
|
| 64 |
+ for (uint8_t i = 0; i < this->nTracks; ++i) |
|
| 65 |
+ this->tracks[this->trackIds[i]].Free(); |
|
| 66 |
+ this->nTracks = 0; |
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+void Player::Stop(bool bKillSound) |
|
| 70 |
+{
|
|
| 71 |
+ this->ClearState(); |
|
| 72 |
+ for (uint8_t i = 0; i < this->nTracks; ++i) |
|
| 73 |
+ {
|
|
| 74 |
+ uint8_t trackId = this->trackIds[i]; |
|
| 75 |
+ this->tracks[trackId].ClearState(); |
|
| 76 |
+ for (int j = 0; j < 16; ++j) |
|
| 77 |
+ {
|
|
| 78 |
+ Channel &chn = this->channels[j]; |
|
| 79 |
+ if (chn.state != CS_NONE && chn.trackId == trackId) |
|
| 80 |
+ {
|
|
| 81 |
+ if (bKillSound) |
|
| 82 |
+ chn.Kill(); |
|
| 83 |
+ else |
|
| 84 |
+ chn.Release(); |
|
| 85 |
+ } |
|
| 86 |
+ } |
|
| 87 |
+ } |
|
| 88 |
+ this->FreeTracks(); |
|
| 89 |
+} |
|
| 90 |
+ |
|
| 62 | 91 |
int Player::ChannelAlloc(int type, int priority) |
| 63 | 92 |
{
|
| 64 | 93 |
static const uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
|
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Player structure |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-21 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -35,6 +35,8 @@ struct Player |
| 35 | 35 |
|
| 36 | 36 |
bool Setup(const SSEQ *sseq); |
| 37 | 37 |
void ClearState(); |
| 38 |
+ void FreeTracks(); |
|
| 39 |
+ void Stop(bool bKillSound); |
|
| 38 | 40 |
int ChannelAlloc(int type, int prio); |
| 39 | 41 |
int TrackAlloc(); |
| 40 | 42 |
void Run(); |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Track structure |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -86,6 +86,12 @@ void Track::ClearState() |
| 86 | 86 |
this->modDepth = 0; |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 |
+void Track::Free() |
|
| 90 |
+{
|
|
| 91 |
+ this->state.reset(); |
|
| 92 |
+ this->updateFlags.reset(); |
|
| 93 |
+} |
|
| 94 |
+ |
|
| 89 | 95 |
int Track::NoteOn(int key, int vel, int len) |
| 90 | 96 |
{
|
| 91 | 97 |
auto sbnk = this->ply->sseq->bank; |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Track structure |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-21 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -52,6 +52,7 @@ struct Track |
| 52 | 52 |
void Init(uint8_t handle, Player *ply, const uint8_t *pos, int n); |
| 53 | 53 |
void Zero(); |
| 54 | 54 |
void ClearState(); |
| 55 |
+ void Free(); |
|
| 55 | 56 |
int NoteOn(int key, int vel, int len); |
| 56 | 57 |
int NoteOnTie(int key, int vel); |
| 57 | 58 |
void ReleaseAllNotes(); |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - NCSF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
* |
| ... | ... |
@@ -194,6 +194,11 @@ void XSFPlayer_NCSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 194 | 194 |
} |
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 |
+void XSFPlayer_NCSF::Terminate() |
|
| 198 |
+{
|
|
| 199 |
+ this->player.Stop(true); |
|
| 200 |
+} |
|
| 201 |
+ |
|
| 197 | 202 |
void XSFPlayer_NCSF::SetInterpolation(unsigned interpolation) |
| 198 | 203 |
{
|
| 199 | 204 |
this->player.interpolation = static_cast<Interpolation>(interpolation); |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - NCSF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-01 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
* |
| ... | ... |
@@ -36,7 +36,7 @@ public: |
| 36 | 36 |
XSFPlayer_NCSF(const std::wstring &filename); |
| 37 | 37 |
bool Load(); |
| 38 | 38 |
void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples); |
| 39 |
- void Terminate() { }
|
|
| 39 |
+ void Terminate(); |
|
| 40 | 40 |
|
| 41 | 41 |
void SetInterpolation(unsigned interpolation); |
| 42 | 42 |
void SetMutes(const std::bitset<16> &newMutes); |