Path: blob/master/libmeteor/include/ameteor/audio/sound4.hpp
2 views
// Meteor - A Nintendo Gameboy Advance emulator1// Copyright (C) 2009-2011 Philippe Daouadi2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// This program is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program. If not, see <http://www.gnu.org/licenses/>.1516#ifndef __AUDIO_SOUND_4_H__17#define __AUDIO_SOUND_4_H__1819#include <stdint.h>20#include <istream>21#include <ostream>2223namespace AMeteor24{25namespace Audio26{27void InitNoise ();2829class Sound430{31public :32Sound4 (uint16_t& cntl, uint16_t& cnth, uint16_t freq);3334void Reset ();3536// call this at the frequence given in constructor37void SoundTick ();3839void ResetSound ();40void ResetEnvelope ()41{42m_envelope = 0;43}4445int8_t GetSample () const46{47return m_sample;48}4950bool IsOn () const51{52return m_on;53}5455bool SaveState (std::ostream& stream);56bool LoadState (std::istream& stream);5758private :59uint16_t &m_cntl, &m_cnth;60bool m_on;61// positions in Period, position in noise and Envelope step time62uint32_t m_posP, m_posN, m_posE;63int8_t m_sample;64// sample period in cycles65uint16_t m_speriod;66// envelope level67uint8_t m_envelope;68// sound length in cycles69uint32_t m_length;70bool m_timed;71// clock divider72uint8_t m_div;73};74}75}7677#endif787980