Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/include/ameteor/audio/sound1.hpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef __AUDIO_SOUND_1_H__
18
#define __AUDIO_SOUND_1_H__
19
20
#include <stdint.h>
21
#include <istream>
22
#include <ostream>
23
24
namespace AMeteor
25
{
26
namespace Audio
27
{
28
class Sound1
29
{
30
public :
31
Sound1 (uint16_t& cntl, uint16_t& cnth, uint16_t& cntx,
32
uint16_t freq);
33
34
void Reset ();
35
36
// call this at the frequence given in constructor
37
void SoundTick ();
38
39
void ResetSound ();
40
void ResetEnvelope ()
41
{
42
m_envelope = 0;
43
}
44
45
int8_t GetSample () const
46
{
47
return m_sample;
48
}
49
50
bool IsOn () const
51
{
52
return m_on;
53
}
54
55
bool SaveState (std::ostream& stream);
56
bool LoadState (std::istream& stream);
57
58
private :
59
uint16_t &m_cntl, &m_cnth, &m_cntx;
60
bool m_on;
61
// positions in Period, Sweep time and Envelope step time
62
uint32_t m_posP, m_posS, m_posE;
63
int8_t m_sample;
64
// sample period in cycles
65
uint16_t m_speriod;
66
// envelope level
67
uint8_t m_envelope;
68
// sound length in cycles
69
uint32_t m_length;
70
bool m_timed;
71
};
72
}
73
}
74
75
#endif
76
77