mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 01:26:31 +01:00
Remove abstract MIDIFile interface (maintaining interface with old crap was getting annoying).
git-svn-id: svn://localhost/ardour2/branches/3.0@4553 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
5ffdf1857e
commit
d439459589
5 changed files with 12 additions and 77 deletions
|
|
@ -1,68 +0,0 @@
|
||||||
/* This file is part of Evoral.
|
|
||||||
* Copyright(C) 2008 Dave Robillard <http://drobilla.net>
|
|
||||||
* Copyright(C) 2000-2008 Paul Davis
|
|
||||||
* Author: Hans Baier
|
|
||||||
*
|
|
||||||
* Evoral is free software; you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation; either version 2 of the License, or(at your option) any later
|
|
||||||
* version.
|
|
||||||
*
|
|
||||||
* Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EVORAL_STANDARD_MIDI_FILE_HPP
|
|
||||||
#define EVORAL_STANDARD_MIDI_FILE_HPP
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "evoral/types.hpp"
|
|
||||||
|
|
||||||
namespace Evoral {
|
|
||||||
|
|
||||||
template<typename Time> class Event;
|
|
||||||
template<typename Time> class EventRingBuffer;
|
|
||||||
|
|
||||||
#define THROW_FILE_ERROR throw(typename MIDIFile<Time>::FileError)
|
|
||||||
|
|
||||||
/** Standard MIDI File interface
|
|
||||||
*/
|
|
||||||
template<typename Time>
|
|
||||||
class MIDIFile {
|
|
||||||
public:
|
|
||||||
class FileError : public std::exception {
|
|
||||||
const char* what() const throw() { return "libsmf error"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void seek_to_start() const = 0;
|
|
||||||
|
|
||||||
virtual uint16_t ppqn() const = 0;
|
|
||||||
virtual bool is_empty() const = 0;
|
|
||||||
virtual bool eof() const = 0;
|
|
||||||
|
|
||||||
virtual Time last_event_time() const = 0;
|
|
||||||
|
|
||||||
virtual void begin_write() = 0;
|
|
||||||
virtual void append_event_delta(uint32_t delta_t, const Event<Time>& ev) = 0;
|
|
||||||
virtual void end_write() throw(FileError) = 0;
|
|
||||||
|
|
||||||
virtual void flush() = 0;
|
|
||||||
virtual int flush_header() = 0;
|
|
||||||
virtual int flush_footer() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int open(const std::string& path) throw(FileError) = 0;
|
|
||||||
virtual void close() throw(FileError) = 0;
|
|
||||||
|
|
||||||
virtual int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; /* namespace Evoral */
|
|
||||||
|
|
||||||
#endif /* EVORAL_STANDARD_MIDI_FILE_HPP */
|
|
||||||
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
#ifndef EVORAL_OLD_SMF_HPP
|
#ifndef EVORAL_OLD_SMF_HPP
|
||||||
#define EVORAL_OLD_SMF_HPP
|
#define EVORAL_OLD_SMF_HPP
|
||||||
|
|
||||||
#include "evoral/MIDIFile.hpp"
|
|
||||||
|
|
||||||
namespace Evoral {
|
namespace Evoral {
|
||||||
|
|
||||||
template<typename Time> class Event;
|
template<typename Time> class Event;
|
||||||
|
|
@ -30,7 +28,7 @@ template<typename Time> class EventRingBuffer;
|
||||||
/** Standard Midi File (Type 0)
|
/** Standard Midi File (Type 0)
|
||||||
*/
|
*/
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
class SMF : public MIDIFile<Time> {
|
class SMF {
|
||||||
public:
|
public:
|
||||||
SMF();
|
SMF();
|
||||||
virtual ~SMF();
|
virtual ~SMF();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#define EVORAL_SMF_HPP
|
#define EVORAL_SMF_HPP
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "evoral/MIDIFile.hpp"
|
|
||||||
|
|
||||||
struct smf_struct;
|
struct smf_struct;
|
||||||
struct smf_track_struct;
|
struct smf_track_struct;
|
||||||
|
|
@ -33,11 +32,17 @@ namespace Evoral {
|
||||||
template<typename Time> class Event;
|
template<typename Time> class Event;
|
||||||
template<typename Time> class EventRingBuffer;
|
template<typename Time> class EventRingBuffer;
|
||||||
|
|
||||||
|
#define THROW_FILE_ERROR throw(typename SMF<Time>::FileError)
|
||||||
|
|
||||||
/** Standard Midi File (Type 0)
|
/** Standard Midi File (Type 0)
|
||||||
*/
|
*/
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
class SMF : public MIDIFile<Time> {
|
class SMF {
|
||||||
public:
|
public:
|
||||||
|
class FileError : public std::exception {
|
||||||
|
const char* what() const throw() { return "Unknown SMF error"; }
|
||||||
|
};
|
||||||
|
|
||||||
SMF() : _last_ev_time(0), _smf(0), _smf_track(0), _empty(true) {};
|
SMF() : _last_ev_time(0), _smf(0), _smf_track(0), _empty(true) {};
|
||||||
virtual ~SMF();
|
virtual ~SMF();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ SMF<Time>::begin_write()
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
SMF<Time>::end_write() throw(typename MIDIFile<Time>::FileError)
|
SMF<Time>::end_write()
|
||||||
{
|
{
|
||||||
flush_header();
|
flush_header();
|
||||||
flush_footer();
|
flush_footer();
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ SMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
||||||
if (!_smf) {
|
if (!_smf) {
|
||||||
_smf = smf_new();
|
_smf = smf_new();
|
||||||
if (smf_set_ppqn(_smf, _ppqn) != 0) {
|
if (smf_set_ppqn(_smf, _ppqn) != 0) {
|
||||||
throw typename MIDIFile<Time>::FileError();
|
throw FileError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_smf == NULL) {
|
if(_smf == NULL) {
|
||||||
|
|
@ -88,7 +88,7 @@ SMF<Time>::close() THROW_FILE_ERROR
|
||||||
{
|
{
|
||||||
if (_smf) {
|
if (_smf) {
|
||||||
if (smf_save(_smf, _path.c_str()) != 0) {
|
if (smf_save(_smf, _path.c_str()) != 0) {
|
||||||
throw typename MIDIFile<Time>::FileError();
|
throw FileError();
|
||||||
}
|
}
|
||||||
smf_delete(_smf);
|
smf_delete(_smf);
|
||||||
_smf = 0;
|
_smf = 0;
|
||||||
|
|
@ -192,7 +192,7 @@ void
|
||||||
SMF<Time>::end_write() THROW_FILE_ERROR
|
SMF<Time>::end_write() THROW_FILE_ERROR
|
||||||
{
|
{
|
||||||
if (smf_save(_smf, _path.c_str()) != 0)
|
if (smf_save(_smf, _path.c_str()) != 0)
|
||||||
throw typename MIDIFile<Time>::FileError();
|
throw FileError();
|
||||||
}
|
}
|
||||||
|
|
||||||
template class SMF<double>;
|
template class SMF<double>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue