Path: blob/master/libmeteor/include/ameteor/audio/sound1.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_1_H__17#define __AUDIO_SOUND_1_H__1819#include <stdint.h>20#include <istream>21#include <ostream>2223namespace AMeteor24{25namespace Audio26{27class Sound128{29public :30Sound1 (uint16_t& cntl, uint16_t& cnth, uint16_t& cntx,31uint16_t freq);3233void Reset ();3435// call this at the frequence given in constructor36void SoundTick ();3738void ResetSound ();39void ResetEnvelope ()40{41m_envelope = 0;42}4344int8_t GetSample () const45{46return m_sample;47}4849bool IsOn () const50{51return m_on;52}5354bool SaveState (std::ostream& stream);55bool LoadState (std::istream& stream);5657private :58uint16_t &m_cntl, &m_cnth, &m_cntx;59bool m_on;60// positions in Period, Sweep time and Envelope step time61uint32_t m_posP, m_posS, m_posE;62int8_t m_sample;63// sample period in cycles64uint16_t m_speriod;65// envelope level66uint8_t m_envelope;67// sound length in cycles68uint32_t m_length;69bool m_timed;70};71}72}7374#endif757677