| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (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 |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #include <hydrogen/event_queue.h> |
|---|
| 24 | #include "H2Transport.h" |
|---|
| 25 | #include "SimpleTransportMaster.h" |
|---|
| 26 | |
|---|
| 27 | using namespace H2Core; |
|---|
| 28 | |
|---|
| 29 | class H2Core::H2TransportPrivate |
|---|
| 30 | { |
|---|
| 31 | public: |
|---|
| 32 | Transport* xport; |
|---|
| 33 | }; |
|---|
| 34 | |
|---|
| 35 | H2Transport::H2Transport() : |
|---|
| 36 | d(0) |
|---|
| 37 | { |
|---|
| 38 | d = new H2TransportPrivate; |
|---|
| 39 | d->xport = new SimpleTransportMaster; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | H2Transport::~H2Transport() |
|---|
| 43 | { |
|---|
| 44 | delete d->xport; |
|---|
| 45 | delete d; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | int H2Transport::locate(uint32_t frame) |
|---|
| 49 | { |
|---|
| 50 | if(d->xport) return d->xport->locate(frame); |
|---|
| 51 | return -1; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | int H2Transport::locate(uint32_t bar, uint32_t beat, uint32_t tick) |
|---|
| 55 | { |
|---|
| 56 | if(d->xport) return d->xport->locate(bar, beat, tick); |
|---|
| 57 | return -1; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | void H2Transport::start(void) |
|---|
| 61 | { |
|---|
| 62 | EventQueue::get_instance()->push_event( EVENT_TRANSPORT, (int)TransportPosition::ROLLING ); |
|---|
| 63 | if(d->xport) d->xport->start(); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | void H2Transport::stop(void) |
|---|
| 67 | { |
|---|
| 68 | EventQueue::get_instance()->push_event( EVENT_TRANSPORT, (int)TransportPosition::STOPPED ); |
|---|
| 69 | if(d->xport) d->xport->stop(); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | void H2Transport::get_position(TransportPosition* pos) |
|---|
| 73 | { |
|---|
| 74 | if(d->xport) d->xport->get_position(pos); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | void H2Transport::processed_frames(uint32_t nFrames) |
|---|
| 78 | { |
|---|
| 79 | if(d->xport) d->xport->processed_frames(nFrames); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | void H2Transport::set_current_song(Song* s) |
|---|
| 83 | { |
|---|
| 84 | if(d->xport) d->xport->set_current_song(s); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | uint32_t H2Transport::get_current_frame() |
|---|
| 88 | { |
|---|
| 89 | if(d->xport) { |
|---|
| 90 | return d->xport->get_current_frame(); |
|---|
| 91 | } |
|---|
| 92 | return (uint32_t)-1; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | TransportPosition::State H2Transport::get_state() |
|---|
| 96 | { |
|---|
| 97 | if(d->xport) { |
|---|
| 98 | return d->xport->get_state(); |
|---|
| 99 | } |
|---|
| 100 | return TransportPosition::STOPPED; |
|---|
| 101 | } |
|---|