mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-18 20:56:28 +01:00
LibSMF -> SMF
git-svn-id: svn://localhost/ardour2/branches/3.0@4552 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6314c69971
commit
5ffdf1857e
6 changed files with 58 additions and 46 deletions
|
|
@ -31,9 +31,9 @@ src/ControlList.cpp
|
||||||
src/ControlSet.cpp
|
src/ControlSet.cpp
|
||||||
src/Curve.cpp
|
src/Curve.cpp
|
||||||
src/Event.cpp
|
src/Event.cpp
|
||||||
src/LibSMF.cpp
|
|
||||||
src/MIDIEvent.cpp
|
src/MIDIEvent.cpp
|
||||||
src/Note.cpp
|
src/Note.cpp
|
||||||
|
src/SMF.cpp
|
||||||
src/SMFReader.cpp
|
src/SMFReader.cpp
|
||||||
src/Sequence.cpp
|
src/Sequence.cpp
|
||||||
""")
|
""")
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EVORAL_SMF_HPP
|
#ifndef EVORAL_OLD_SMF_HPP
|
||||||
#define EVORAL_SMF_HPP
|
#define EVORAL_OLD_SMF_HPP
|
||||||
|
|
||||||
#include "evoral/MIDIFile.hpp"
|
#include "evoral/MIDIFile.hpp"
|
||||||
|
|
||||||
|
|
@ -80,5 +80,5 @@ private:
|
||||||
|
|
||||||
}; /* namespace Evoral */
|
}; /* namespace Evoral */
|
||||||
|
|
||||||
#endif /* EVORAL_SMF_HPP */
|
#endif /* EVORAL_OLD_SMF_HPP */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EVORAL_LIB_SMF_HPP
|
#ifndef EVORAL_SMF_HPP
|
||||||
#define EVORAL_LIB_SMF_HPP
|
#define EVORAL_SMF_HPP
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "evoral/MIDIFile.hpp"
|
#include "evoral/MIDIFile.hpp"
|
||||||
|
|
@ -36,10 +36,10 @@ template<typename Time> class EventRingBuffer;
|
||||||
/** Standard Midi File (Type 0)
|
/** Standard Midi File (Type 0)
|
||||||
*/
|
*/
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
class LibSMF : public MIDIFile<Time> {
|
class SMF : public MIDIFile<Time> {
|
||||||
public:
|
public:
|
||||||
LibSMF() : _last_ev_time(0), _smf(0), _smf_track(0), _empty(true) {};
|
SMF() : _last_ev_time(0), _smf(0), _smf_track(0), _empty(true) {};
|
||||||
virtual ~LibSMF();
|
virtual ~SMF();
|
||||||
|
|
||||||
void seek_to_start() const;
|
void seek_to_start() const;
|
||||||
|
|
||||||
|
|
@ -77,5 +77,5 @@ private:
|
||||||
|
|
||||||
}; /* namespace Evoral */
|
}; /* namespace Evoral */
|
||||||
|
|
||||||
#endif /* EVORAL_LIB_SMF_HPP */
|
#endif /* EVORAL_SMF_HPP */
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "evoral/Event.hpp"
|
#include "evoral/Event.hpp"
|
||||||
#include "evoral/LibSMF.hpp"
|
#include "evoral/SMF.hpp"
|
||||||
#include "libsmf/smf.h"
|
#include "libsmf/smf.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -28,7 +28,7 @@ using namespace std;
|
||||||
namespace Evoral {
|
namespace Evoral {
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
LibSMF<Time>::~LibSMF()
|
SMF<Time>::~SMF()
|
||||||
{
|
{
|
||||||
if (_smf) {
|
if (_smf) {
|
||||||
smf_delete(_smf);
|
smf_delete(_smf);
|
||||||
|
|
@ -46,7 +46,7 @@ LibSMF<Time>::~LibSMF()
|
||||||
*/
|
*/
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
int
|
int
|
||||||
LibSMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
SMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
||||||
{
|
{
|
||||||
if (_smf) {
|
if (_smf) {
|
||||||
smf_delete(_smf);
|
smf_delete(_smf);
|
||||||
|
|
@ -84,7 +84,7 @@ LibSMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
LibSMF<Time>::close() THROW_FILE_ERROR
|
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) {
|
||||||
|
|
@ -98,7 +98,7 @@ LibSMF<Time>::close() THROW_FILE_ERROR
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
LibSMF<Time>::seek_to_start() const
|
SMF<Time>::seek_to_start() const
|
||||||
{
|
{
|
||||||
smf_rewind(_smf);
|
smf_rewind(_smf);
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ LibSMF<Time>::seek_to_start() const
|
||||||
*/
|
*/
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
int
|
int
|
||||||
LibSMF<Time>::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const
|
SMF<Time>::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const
|
||||||
{
|
{
|
||||||
smf_event_t *event;
|
smf_event_t *event;
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ LibSMF<Time>::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
LibSMF<Time>::append_event_delta(uint32_t delta_t, const Event<Time>& ev)
|
SMF<Time>::append_event_delta(uint32_t delta_t, const Event<Time>& ev)
|
||||||
{
|
{
|
||||||
assert(ev.size() > 0);
|
assert(ev.size() > 0);
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ LibSMF<Time>::append_event_delta(uint32_t delta_t, const Event<Time>& ev)
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
LibSMF<Time>::begin_write()
|
SMF<Time>::begin_write()
|
||||||
{
|
{
|
||||||
assert(_smf_track);
|
assert(_smf_track);
|
||||||
smf_track_delete(_smf_track);
|
smf_track_delete(_smf_track);
|
||||||
|
|
@ -189,12 +189,12 @@ LibSMF<Time>::begin_write()
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
void
|
void
|
||||||
LibSMF<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 typename MIDIFile<Time>::FileError();
|
||||||
}
|
}
|
||||||
|
|
||||||
template class LibSMF<double>;
|
template class SMF<double>;
|
||||||
|
|
||||||
} // namespace Evoral
|
} // namespace Evoral
|
||||||
|
|
@ -1,38 +1,50 @@
|
||||||
#include <cppunit/TestFixture.h>
|
/* This file is part of Evoral.
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
* Copyright(C) 2000-2008 Paul Davis
|
||||||
|
* Author: Hans Baier
|
||||||
#include <evoral/LibSMF.hpp>
|
*
|
||||||
|
* Evoral is free software; you can redistribute it and/or modify it under the
|
||||||
#include "SequenceTest.hpp"
|
* 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
|
||||||
#include <sigc++/sigc++.h>
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <sigc++/sigc++.h>
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include "evoral/SMF.hpp"
|
||||||
|
#include "SequenceTest.hpp"
|
||||||
|
|
||||||
using namespace Evoral;
|
using namespace Evoral;
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
class TestSMF : public LibSMF<Time> {
|
class TestSMF : public SMF<Time> {
|
||||||
public:
|
public:
|
||||||
std::string path() const { return _path; }
|
std::string path() const { return _path; }
|
||||||
|
|
||||||
int open(const std::string& path) THROW_FILE_ERROR {
|
int open(const std::string& path) THROW_FILE_ERROR {
|
||||||
_path = path;
|
_path = path;
|
||||||
return LibSMF<Time>::open(path);
|
return SMF<Time>::open(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() THROW_FILE_ERROR {
|
void close() THROW_FILE_ERROR {
|
||||||
return LibSMF<Time>::close();
|
return SMF<Time>::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
|
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
|
||||||
return LibSMF<Time>::read_event(delta_t, size, buf);
|
return SMF<Time>::read_event(delta_t, size, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _path;
|
std::string _path;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SMFTest : public CppUnit::TestFixture
|
class SMFTest : public CppUnit::TestFixture
|
||||||
|
|
@ -43,25 +55,25 @@ class SMFTest : public CppUnit::TestFixture
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef double Time;
|
typedef double Time;
|
||||||
|
|
||||||
void setUp (void) {
|
void setUp() {
|
||||||
type_map = new DummyTypeMap();
|
type_map = new DummyTypeMap();
|
||||||
assert(type_map);
|
assert(type_map);
|
||||||
seq = new MySequence<Time>(*type_map, 0);
|
seq = new MySequence<Time>(*type_map, 0);
|
||||||
assert(seq);
|
assert(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown (void) {
|
void tearDown() {
|
||||||
delete seq;
|
delete seq;
|
||||||
delete type_map;
|
delete type_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createNewFileTest(void);
|
void createNewFileTest();
|
||||||
void takeFiveTest (void);
|
void takeFiveTest();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DummyTypeMap* type_map;
|
DummyTypeMap* type_map;
|
||||||
MySequence<Time>* seq;
|
MySequence<Time>* seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ def build(bld):
|
||||||
src/ControlSet.cpp
|
src/ControlSet.cpp
|
||||||
src/Curve.cpp
|
src/Curve.cpp
|
||||||
src/Event.cpp
|
src/Event.cpp
|
||||||
src/LibSMF.cpp
|
|
||||||
src/MIDIEvent.cpp
|
src/MIDIEvent.cpp
|
||||||
src/Note.cpp
|
src/Note.cpp
|
||||||
|
src/SMF.cpp
|
||||||
src/Sequence.cpp
|
src/Sequence.cpp
|
||||||
'''
|
'''
|
||||||
obj.export_incdirs = ['.']
|
obj.export_incdirs = ['.']
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue