summaryrefslogtreecommitdiffstats
path: root/src/base/ScriptAPI.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:37:05 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:37:05 +0000
commit145364a8af6a1fec06556221e66d4b724a62fc9a (patch)
tree53bd71a544008c518034f208d64c932dc2883f50 /src/base/ScriptAPI.h
downloadrosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz
rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/base/ScriptAPI.h')
-rw-r--r--src/base/ScriptAPI.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/base/ScriptAPI.h b/src/base/ScriptAPI.h
new file mode 100644
index 0000000..8d721a4
--- /dev/null
+++ b/src/base/ScriptAPI.h
@@ -0,0 +1,128 @@
+// -*- c-basic-offset: 4 -*-
+
+/*
+ Rosegarden
+ A sequencer and musical notation editor.
+
+ This program is Copyright 2000-2004
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral right of the authors to claim authorship of this work
+ has been asserted.
+
+ This program 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. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _SCRIPT_API_H_
+#define _SCRIPT_API_H_
+
+#include "Segment.h"
+
+namespace Rosegarden
+{
+
+class Composition;
+
+class ScriptInterface
+{
+public:
+ typedef int ScriptId;
+ typedef int SegmentId;
+ typedef int EventId;
+ typedef int ScriptTime;
+
+ // Resolution defines the meaning of ScriptTime units. If set to
+ // the QuantizedNN values, each ScriptTime unit will correspond to
+ // the duration of an NN-th note. If Unquantized, ScriptTime will
+ // correspond to timeT, i.e. 960 to a quarter note.
+ // And Notation is like Quantized64 except that the times are
+ // obtained from the notation time and duration properties of each
+ // event instead of the raw ones.
+
+ enum Resolution {
+ Unquantized,
+ Notation,
+ Quantized64,
+ Quantized32,
+ Quantized16
+ };
+
+ enum Scope {
+ Global,
+ Segment
+ };
+
+ class ScriptEvent {
+ EventId id;
+ int bar; // number, 1-based
+ ScriptTime time; // within bar
+ ScriptTime duration;
+ int pitch; // 0-127 if note, -1 otherwise
+ };
+
+ class ScriptTimeSignature {
+ int numerator;
+ int denominator;
+ ScriptTime duration;
+ };
+
+ class ScriptKeySignature {
+ int accidentals;
+ bool sharps;
+ bool minor;
+ };
+
+ ScriptInterface(Composition *composition);
+ virtual ~ScriptInterface();
+
+ ScriptId createScript(SegmentId target, Resolution resolution, Scope scope);
+ void destroyScript(ScriptId id);
+
+ // A script can only proceed forwards. The getEvent and getNote
+ // methods get the next event (including notes) or note within the
+ // current chord or timeslice; the advance method moves forwards
+ // to the next chord or other event. So to process through all
+ // events, call advance() followed by a loop of getEvent() calls
+ // before the next advance(), and so on. An event with id -1
+ // marks the end of a slice. ( -1 is an out-of-range value for
+ // all types of id.)
+
+ ScriptEvent getEvent(ScriptId id);
+ ScriptEvent getNote(ScriptId id);
+
+ bool advance(ScriptId id);
+
+ ScriptTimeSignature getTimeSignature(ScriptId id);
+ ScriptKeySignature getKeySignature(ScriptId id);
+
+ EventId addNote(ScriptId id,
+ int bar, ScriptTime time, ScriptTime duration, int pitch);
+
+ EventId addEvent(ScriptId id,
+ std::string type, int bar, ScriptTime time, ScriptTime duration);
+
+ void deleteEvent(ScriptId id, EventId event);
+
+ std::string getEventType(ScriptId id, EventId event);
+ std::string getProperty(ScriptId id, EventId event, std::string property);
+ void setProperty(ScriptId id, EventId event, std::string property, std::string value);
+
+protected:
+ Composition *m_composition;
+
+ class ScriptContainer;
+ ScriptContainer *m_scripts;
+};
+
+}
+
+
+#endif
+
+