Path: blob/master/libmeteor/include/ameteor/audio/sound2.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_2_H__17#define __AUDIO_SOUND_2_H__1819#include <stdint.h>20#include <istream>21#include <ostream>2223namespace AMeteor24{25namespace Audio26{27class Sound228{29public :30Sound2 (uint16_t& cntl, uint16_t& cnth, uint16_t freq);3132void Reset ();3334// call this at the frequence given in constructor35void SoundTick ();3637void ResetSound ();38void ResetEnvelope ()39{40m_envelope = 0;41}4243int8_t GetSample () const44{45return m_sample;46}4748bool IsOn () const49{50return m_on;51}5253bool SaveState (std::ostream& stream);54bool LoadState (std::istream& stream);5556private :57uint16_t &m_cntl, &m_cnth;58bool m_on;59uint32_t m_posP, m_posE;60int8_t m_sample;61uint16_t m_speriod;62uint8_t m_envelope;63uint32_t m_length;64bool m_timed;65};66}67}6869#endif707172