Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/include/ameteor/audio/sound4.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_4_H__
18
#define __AUDIO_SOUND_4_H__
19
20
#include <stdint.h>
21
#include <istream>
22
#include <ostream>
23
24
namespace AMeteor
25
{
26
namespace Audio
27
{
28
void InitNoise ();
29
30
class Sound4
31
{
32
public :
33
Sound4 (uint16_t& cntl, uint16_t& cnth, uint16_t freq);
34
35
void Reset ();
36
37
// call this at the frequence given in constructor
38
void SoundTick ();
39
40
void ResetSound ();
41
void ResetEnvelope ()
42
{
43
m_envelope = 0;
44
}
45
46
int8_t GetSample () const
47
{
48
return m_sample;
49
}
50
51
bool IsOn () const
52
{
53
return m_on;
54
}
55
56
bool SaveState (std::ostream& stream);
57
bool LoadState (std::istream& stream);
58
59
private :
60
uint16_t &m_cntl, &m_cnth;
61
bool m_on;
62
// positions in Period, position in noise and Envelope step time
63
uint32_t m_posP, m_posN, m_posE;
64
int8_t m_sample;
65
// sample period in cycles
66
uint16_t m_speriod;
67
// envelope level
68
uint8_t m_envelope;
69
// sound length in cycles
70
uint32_t m_length;
71
bool m_timed;
72
// clock divider
73
uint8_t m_div;
74
};
75
}
76
}
77
78
#endif
79
80