|
| 1 | +/* |
| 2 | + * Gb_Apu_Buffer.cpp - Gb_Apu subclass which allows direct buffer access |
| 3 | + * Copyright (c) 2017 Tres Finocchiaro <tres.finocchiaro/at/gmail.com> |
| 4 | + * |
| 5 | + * This file is part of LMMS - https://lmms.io |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or |
| 8 | + * modify it under the terms of the GNU General Public |
| 9 | + * License as published by the Free Software Foundation; either |
| 10 | + * version 2 of the License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + * General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public |
| 18 | + * License along with this program (see COPYING); if not, write to the |
| 19 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | + * Boston, MA 02110-1301 USA. |
| 21 | + * |
| 22 | + */ |
| 23 | +#include "Gb_Apu.h" |
| 24 | +#include "Gb_Apu_Buffer.h" |
| 25 | + |
| 26 | +blip_time_t const FRAME_LENGTH = 70224; |
| 27 | +long const CLOCK_RATE = 4194304; |
| 28 | + |
| 29 | +Gb_Apu_Buffer::Gb_Apu_Buffer() : m_time(0) {} |
| 30 | +Gb_Apu_Buffer::~Gb_Apu_Buffer() {} |
| 31 | + |
| 32 | +void Gb_Apu_Buffer::write_register(blip_time_t ignore, unsigned addr, int data) { |
| 33 | + Gb_Apu::write_register(clock(), addr, data); |
| 34 | +} |
| 35 | + |
| 36 | +int Gb_Apu_Buffer::read_register(blip_time_t ignore, unsigned addr) { |
| 37 | + return Gb_Apu::read_register(clock(), addr); |
| 38 | +} |
| 39 | + |
| 40 | +void Gb_Apu_Buffer::end_frame(blip_time_t ignore) { |
| 41 | + m_time = 0; |
| 42 | + Gb_Apu::end_frame(FRAME_LENGTH); |
| 43 | + m_buf.end_frame(FRAME_LENGTH); |
| 44 | +} |
| 45 | + |
| 46 | +// Sets specified sample rate and hard-coded clock rate in Multi_Buffer |
| 47 | +blargg_err_t Gb_Apu_Buffer::set_sample_rate(long rate) { |
| 48 | + Gb_Apu_Buffer::output(m_buf.center(), m_buf.left(), m_buf.right()); |
| 49 | + m_buf.clock_rate(CLOCK_RATE); |
| 50 | + return m_buf.set_sample_rate(rate); |
| 51 | +} |
| 52 | + |
| 53 | +// Wrap Multi_Buffer::samples_avail() |
| 54 | +long Gb_Apu_Buffer::samples_avail() const { |
| 55 | + return m_buf.samples_avail(); |
| 56 | +} |
| 57 | + |
| 58 | +// Wrap Multi_Buffer::read_samples(...) |
| 59 | +long Gb_Apu_Buffer::read_samples(sample_t* out, long count) { |
| 60 | + return m_buf.read_samples(out, count); |
| 61 | +} |
| 62 | + |
| 63 | +void Gb_Apu_Buffer::bass_freq(int freq) { |
| 64 | + m_buf.bass_freq(freq); |
| 65 | +} |
| 66 | + |
0 commit comments