infrastructure for save/restore of MIDI port user-provided information
[ardour.git] / libs / ardour / ardour / types.h
1 /*
2     Copyright (C) 2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_types_h__
21 #define __ardour_types_h__
22
23 #include <istream>
24 #include <vector>
25 #include <map>
26 #include <boost/shared_ptr.hpp>
27 #include <sys/types.h>
28 #include <stdint.h>
29 #include <pthread.h>
30
31 #include <inttypes.h>
32
33 #include "timecode/bbt_time.h"
34 #include "timecode/time.h"
35
36 #include "pbd/id.h"
37
38 #include "evoral/Range.hpp"
39
40 #include "ardour/chan_count.h"
41 #include "ardour/plugin_types.h"
42
43 #include <map>
44
45 #if __GNUC__ < 3
46 typedef int intptr_t;
47 #endif
48
49 namespace ARDOUR {
50
51         class Source;
52         class AudioSource;
53         class Route;
54         class Region;
55         class Stripable;
56         class VCA;
57         class AutomationControl;
58
59         typedef float    Sample;
60         typedef float    pan_t;
61         typedef float    gain_t;
62         typedef uint32_t layer_t;
63         typedef uint64_t microseconds_t;
64         typedef uint32_t pframes_t;
65
66         /* Any position measured in audio frames.
67            Assumed to be non-negative but not enforced.
68         */
69         typedef int64_t framepos_t;
70
71         /* Any distance from a given framepos_t.
72            Maybe positive or negative.
73         */
74         typedef int64_t frameoffset_t;
75
76         /* Any count of audio frames.
77            Assumed to be positive but not enforced.
78         */
79         typedef int64_t framecnt_t;
80
81         static const framepos_t max_framepos = INT64_MAX;
82         static const framecnt_t max_framecnt = INT64_MAX;
83         static const layer_t    max_layer    = UINT32_MAX;
84
85         // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
86         typedef std::list<std::pair<frameoffset_t, frameoffset_t> > AudioIntervalResult;
87         // associate a set of intervals with regions (e.g. for silence detection)
88         typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
89
90         typedef std::list<boost::shared_ptr<Region> > RegionList;
91
92         struct IOChange {
93
94                 enum Type {
95                         NoChange = 0,
96                         ConfigurationChanged = 0x1,
97                         ConnectionsChanged = 0x2
98                 } type;
99
100                 IOChange () : type (NoChange) {}
101                 IOChange (Type t) : type (t) {}
102
103                 /** channel count of IO before a ConfigurationChanged, if appropriate */
104                 ARDOUR::ChanCount before;
105                 /** channel count of IO after a ConfigurationChanged, if appropriate */
106                 ARDOUR::ChanCount after;
107         };
108
109         /* policies for inserting/pasting material where overlaps
110            might be an issue.
111         */
112
113         enum InsertMergePolicy {
114                 InsertMergeReject,  ///< no overlaps allowed
115                 InsertMergeRelax,   ///< we just don't care about overlaps
116                 InsertMergeReplace, ///< replace old with new
117                 InsertMergeTruncateExisting, ///< shorten existing to avoid overlap
118                 InsertMergeTruncateAddition, ///< shorten new to avoid overlap
119                 InsertMergeExtend   ///< extend new (or old) to the range of old+new
120         };
121
122         /** See evoral/Parameter.hpp
123          *
124          * When you add things here, you REALLY SHOULD add a case clause to
125          * the constructor of ParameterDescriptor, unless the Controllables
126          * that the enum refers to are completely standard (0-1.0 range, 0.0 as
127          * normal, non-toggled, non-enumerated). Anything else needs to be
128          * added there so that things that try to represent them can do so
129          * with as much information as possible.
130          */
131         enum AutomationType {
132                 NullAutomation,
133                 GainAutomation,
134                 PanAzimuthAutomation,
135                 PanElevationAutomation,
136                 PanWidthAutomation,
137                 PanFrontBackAutomation,
138                 PanLFEAutomation,
139                 PluginAutomation,
140                 PluginPropertyAutomation,
141                 SoloAutomation,
142                 SoloIsolateAutomation,
143                 SoloSafeAutomation,
144                 MuteAutomation,
145                 MidiCCAutomation,
146                 MidiPgmChangeAutomation,
147                 MidiPitchBenderAutomation,
148                 MidiChannelPressureAutomation,
149                 MidiNotePressureAutomation,
150                 MidiSystemExclusiveAutomation,
151                 FadeInAutomation,
152                 FadeOutAutomation,
153                 EnvelopeAutomation,
154                 RecEnableAutomation,
155                 RecSafeAutomation,
156                 TrimAutomation,
157                 PhaseAutomation,
158                 MonitoringAutomation,
159                 EQGain,
160                 EQFrequency,
161                 EQQ,
162                 EQShape,
163                 EQHPF,
164                 EQEnable,
165                 CompThreshold,
166                 CompSpeed,
167                 CompMode,
168                 CompMakeup,
169                 CompRedux,
170                 CompEnable,
171                 BusSendLevel,
172                 BusSendEnable,
173         };
174
175         enum AutoState {
176                 Off = 0x0,
177                 Write = 0x1,
178                 Touch = 0x2,
179                 Play = 0x4
180         };
181
182         std::string auto_state_to_string (AutoState);
183         AutoState string_to_auto_state (std::string);
184
185         enum AutoStyle {
186                 Absolute = 0x1,
187                 Trim = 0x2
188         };
189
190         std::string auto_style_to_string (AutoStyle);
191         AutoStyle string_to_auto_style (std::string);
192
193         enum AlignStyle {
194                 CaptureTime,
195                 ExistingMaterial
196         };
197
198         enum AlignChoice {
199                 UseCaptureTime,
200                 UseExistingMaterial,
201                 Automatic
202         };
203
204         enum MeterPoint {
205                 MeterInput,
206                 MeterPreFader,
207                 MeterPostFader,
208                 MeterOutput,
209                 MeterCustom
210         };
211
212         enum MeterType {
213                 MeterMaxSignal = 0x0001,
214                 MeterMaxPeak   = 0x0002,
215                 MeterPeak      = 0x0004,
216                 MeterKrms      = 0x0008,
217                 MeterK20       = 0x0010,
218                 MeterK14       = 0x0020,
219                 MeterIEC1DIN   = 0x0040,
220                 MeterIEC1NOR   = 0x0080,
221                 MeterIEC2BBC   = 0x0100,
222                 MeterIEC2EBU   = 0x0200,
223                 MeterVU        = 0x0400,
224                 MeterK12       = 0x0800,
225                 MeterPeak0dB   = 0x1000,
226                 MeterMCP       = 0x2000
227         };
228
229         enum TrackMode {
230                 Normal,
231                 NonLayered,
232                 Destructive
233         };
234
235         enum NoteMode {
236                 Sustained,
237                 Percussive
238         };
239
240         enum ChannelMode {
241                 AllChannels = 0, ///< Pass through all channel information unmodified
242                 FilterChannels,  ///< Ignore events on certain channels
243                 ForceChannel     ///< Force all events to a certain channel
244         };
245
246         enum ColorMode {
247                 MeterColors = 0,
248                 ChannelColors,
249                 TrackColor
250         };
251
252         enum RoundMode {
253                 RoundDownMaybe  = -2,  ///< Round down only if necessary
254                 RoundDownAlways = -1,  ///< Always round down, even if on a division
255                 RoundNearest    = 0,   ///< Round to nearest
256                 RoundUpAlways   = 1,   ///< Always round up, even if on a division
257                 RoundUpMaybe    = 2    ///< Round up only if necessary
258         };
259
260         class AnyTime {
261         public:
262                 enum Type {
263                         Timecode,
264                         BBT,
265                         Frames,
266                         Seconds
267                 };
268
269                 Type type;
270
271                 Timecode::Time     timecode;
272                 Timecode::BBT_Time bbt;
273
274                 union {
275                         framecnt_t     frames;
276                         double         seconds;
277                 };
278
279                 AnyTime() { type = Frames; frames = 0; }
280
281                 bool operator== (AnyTime const & other) const {
282                         if (type != other.type) { return false; }
283
284                         switch (type) {
285                           case Timecode:
286                                 return timecode == other.timecode;
287                           case BBT:
288                                 return bbt == other.bbt;
289                           case Frames:
290                                 return frames == other.frames;
291                           case Seconds:
292                                 return seconds == other.seconds;
293                         }
294                         return false; // get rid of warning
295                 }
296
297                 bool not_zero() const
298                 {
299                         switch (type) {
300                           case Timecode:
301                                 return timecode.hours != 0 || timecode.minutes != 0 ||
302                                        timecode.seconds != 0 || timecode.frames != 0;
303                           case BBT:
304                                 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
305                           case Frames:
306                                 return frames != 0;
307                           case Seconds:
308                                 return seconds != 0;
309                         }
310
311                         abort(); /* NOTREACHED */
312                         return false;
313                 }
314         };
315
316         /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
317            but this has a uint32_t id which Evoral::Range<> does not.
318         */
319         struct AudioRange {
320                 framepos_t start;
321                 framepos_t end;
322                 uint32_t id;
323
324                 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
325
326                 framecnt_t length() const { return end - start + 1; }
327
328                 bool operator== (const AudioRange& other) const {
329                         return start == other.start && end == other.end && id == other.id;
330                 }
331
332                 bool equal (const AudioRange& other) const {
333                         return start == other.start && end == other.end;
334                 }
335
336                 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
337                         return Evoral::coverage (start, end, s, e);
338                 }
339         };
340
341         struct MusicRange {
342                 Timecode::BBT_Time start;
343                 Timecode::BBT_Time end;
344                 uint32_t id;
345
346                 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
347                         : start (s), end (e), id (i) {}
348
349                 bool operator== (const MusicRange& other) const {
350                         return start == other.start && end == other.end && id == other.id;
351                 }
352
353                 bool equal (const MusicRange& other) const {
354                         return start == other.start && end == other.end;
355                 }
356         };
357
358         /*
359             Slowest = 6.6dB/sec falloff at update rate of 40ms
360             Slow    = 6.8dB/sec falloff at update rate of 40ms
361         */
362
363         enum MeterFalloff {
364                 MeterFalloffOff = 0,
365                 MeterFalloffSlowest = 1,
366                 MeterFalloffSlow = 2,
367                 MeterFalloffSlowish = 3,
368                 MeterFalloffModerate = 4,
369                 MeterFalloffMedium = 5,
370                 MeterFalloffFast = 6,
371                 MeterFalloffFaster = 7,
372                 MeterFalloffFastest = 8,
373         };
374
375         enum MeterHold {
376                 MeterHoldOff = 0,
377                 MeterHoldShort = 40,
378                 MeterHoldMedium = 100,
379                 MeterHoldLong = 200
380         };
381
382         enum EditMode {
383                 Slide,
384                 Splice,
385                 Ripple,
386                 Lock
387         };
388
389         enum RegionSelectionAfterSplit {
390                 None = 0,
391                 NewlyCreatedLeft = 1,  // bit 0
392                 NewlyCreatedRight = 2, // bit 1
393                 NewlyCreatedBoth = 3,
394                 Existing = 4,          // bit 2
395                 ExistingNewlyCreatedLeft = 5,
396                 ExistingNewlyCreatedRight = 6,
397                 ExistingNewlyCreatedBoth = 7
398         };
399
400         enum RegionPoint {
401                 Start,
402                 End,
403                 SyncPoint
404         };
405
406         enum Placement {
407                 PreFader,
408                 PostFader
409         };
410
411         enum MonitorModel {
412                 HardwareMonitoring, ///< JACK does monitoring
413                 SoftwareMonitoring, ///< Ardour does monitoring
414                 ExternalMonitoring  ///< we leave monitoring to the audio hardware
415         };
416
417         enum MonitorChoice {
418                 MonitorAuto = 0,
419                 MonitorInput = 0x1,
420                 MonitorDisk = 0x2,
421                 MonitorCue = 0x4,
422         };
423
424         enum MonitorState {
425                 MonitoringSilence = 0x1,
426                 MonitoringInput = 0x2,
427                 MonitoringDisk = 0x4,
428         };
429
430         enum MeterState {
431                 MeteringInput, ///< meter the input IO, regardless of what is going through the route
432                 MeteringRoute  ///< meter what is going through the route
433         };
434
435         enum VUMeterStandard {
436                 MeteringVUfrench,   // 0VU = -2dBu
437                 MeteringVUamerican, // 0VU =  0dBu
438                 MeteringVUstandard, // 0VU = +4dBu
439                 MeteringVUeight     // 0VU = +8dBu
440         };
441
442         enum MeterLineUp {
443                 MeteringLineUp24,
444                 MeteringLineUp20,
445                 MeteringLineUp18,
446                 MeteringLineUp15
447         };
448
449         enum PFLPosition {
450                 /** PFL signals come from before pre-fader processors */
451                 PFLFromBeforeProcessors,
452                 /** PFL signals come pre-fader but after pre-fader processors */
453                 PFLFromAfterProcessors
454         };
455
456         enum AFLPosition {
457                 /** AFL signals come post-fader and before post-fader processors */
458                 AFLFromBeforeProcessors,
459                 /** AFL signals come post-fader but after post-fader processors */
460                 AFLFromAfterProcessors
461         };
462
463         enum DenormalModel {
464                 DenormalNone,
465                 DenormalFTZ,
466                 DenormalDAZ,
467                 DenormalFTZDAZ
468         };
469
470         enum LayerModel {
471                 LaterHigher,
472                 Manual
473         };
474
475         enum ListenPosition {
476                 AfterFaderListen,
477                 PreFaderListen
478         };
479
480         enum AutoConnectOption {
481                 ManualConnect = 0x0,
482                 AutoConnectPhysical = 0x1,
483                 AutoConnectMaster = 0x2
484         };
485
486     enum TracksAutoNamingRule {
487         UseDefaultNames = 0x1,
488         NameAfterDriver = 0x2
489     };
490
491         enum SampleFormat {
492                 FormatFloat = 0,
493                 FormatInt24,
494                 FormatInt16
495         };
496
497         int format_data_width (ARDOUR::SampleFormat);
498
499         enum CDMarkerFormat {
500                 CDMarkerNone,
501                 CDMarkerCUE,
502                 CDMarkerTOC,
503                 MP4Chaps
504         };
505
506         enum HeaderFormat {
507                 BWF,
508                 WAVE,
509                 WAVE64,
510                 CAF,
511                 AIFF,
512                 iXML,
513                 RF64,
514                 RF64_WAV,
515                 MBWF,
516         };
517
518         struct PeakData {
519                 typedef Sample PeakDatum;
520
521                 PeakDatum min;
522                 PeakDatum max;
523         };
524
525         enum RunContext {
526                 ButlerContext = 0,
527                 TransportContext,
528                 ExportContext
529         };
530
531         enum SyncSource {
532                 /* These are "synonyms". It is important for JACK to be first
533                    both here and in enums.cc, so that the string "JACK" is
534                    correctly recognized in older session and preference files.
535                 */
536                 JACK = 0,
537                 Engine = 0,
538                 MTC,
539                 MIDIClock,
540                 LTC
541         };
542
543         enum ShuttleBehaviour {
544                 Sprung,
545                 Wheel
546         };
547
548         enum ShuttleUnits {
549                 Percentage,
550                 Semitones
551         };
552
553         typedef std::vector<boost::shared_ptr<Source> > SourceList;
554
555         enum SrcQuality {
556                 SrcBest,
557                 SrcGood,
558                 SrcQuick,
559                 SrcFast,
560                 SrcFastest
561         };
562
563         typedef std::list<framepos_t> AnalysisFeatureList;
564
565         typedef std::list<boost::shared_ptr<Route> > RouteList;
566         typedef std::list<boost::shared_ptr<Stripable> > StripableList;
567         typedef std::list<boost::weak_ptr  <Route> > WeakRouteList;
568         typedef std::list<boost::weak_ptr  <Stripable> > WeakStripableList;
569         typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
570
571         typedef std::list<boost::shared_ptr<VCA> > VCAList;
572
573         class Bundle;
574         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
575
576         enum WaveformScale {
577                 Linear,
578                 Logarithmic
579         };
580
581         enum WaveformShape {
582                 Traditional,
583                 Rectified
584         };
585
586         struct CleanupReport {
587                 std::vector<std::string> paths;
588                 size_t                   space;
589         };
590
591         enum PositionLockStyle {
592                 AudioTime,
593                 MusicTime
594         };
595
596         /** A struct used to describe changes to processors in a route.
597          *  This is useful because objects that respond to a change in processors
598          *  can optimise what work they do based on details of what has changed.
599         */
600         struct RouteProcessorChange {
601                 enum Type {
602                         GeneralChange = 0x0,
603                         MeterPointChange = 0x1,
604                         RealTimeChange = 0x2
605                 };
606
607                 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
608                 {}
609
610                 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
611                 {}
612
613                 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
614                 {}
615
616                 /** type of change; "GeneralChange" means anything could have changed */
617                 Type type;
618                 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
619                 bool meter_visibly_changed;
620         };
621
622         struct BusProfile {
623                 AutoConnectOption input_ac;      /* override the RC config for input auto-connection */
624                 AutoConnectOption output_ac;     /* override the RC config for output auto-connection */
625                 uint32_t master_out_channels;    /* how many channels for the master bus */
626                 uint32_t requested_physical_in;  /* now many of the available physical inputs to consider usable */
627                 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
628         };
629
630         enum FadeShape {
631                 FadeLinear,
632                 FadeFast,
633                 FadeSlow,
634                 FadeConstantPower,
635                 FadeSymmetric,
636         };
637
638         enum TransportState {
639                 /* these values happen to match the constants used by JACK but
640                    this equality cannot be assumed.
641                 */
642                 TransportStopped = 0,
643                 TransportRolling = 1,
644                 TransportLooping = 2,
645                 TransportStarting = 3,
646         };
647
648         enum PortFlags {
649                 /* these values happen to match the constants used by JACK but
650                    this equality cannot be assumed.
651                 */
652                 IsInput = 0x1,
653                 IsOutput = 0x2,
654                 IsPhysical = 0x4,
655                 CanMonitor = 0x8,
656                 IsTerminal = 0x10,
657
658                 /* non-JACK related flags */
659                 Hidden = 0x20,
660                 Shadow = 0x40
661         };
662
663         enum MidiPortFlags {
664                 MidiPortMusic = 0x1,
665                 MidiPortControl = 0x2,
666                 MidiPortSelection = 0x4,
667         };
668
669         struct LatencyRange {
670             uint32_t min; //< samples
671             uint32_t max; //< samples
672         };
673
674         enum BufferingPreset {
675                 Small,
676                 Medium,
677                 Large,
678                 Custom,
679         };
680
681         enum AutoReturnTarget {
682                 LastLocate = 0x1,
683                 RangeSelectionStart = 0x2,
684                 Loop = 0x4,
685                 RegionSelectionStart = 0x8,
686         };
687
688         enum PlaylistDisposition {
689                 CopyPlaylist,
690                 NewPlaylist,
691                 SharePlaylist
692         };
693
694 } // namespace ARDOUR
695
696
697 /* these cover types declared above in this header. See enums.cc
698    for the definitions.
699 */
700 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
701 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
702 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
703 std::istream& operator>>(std::istream& o, ARDOUR::TracksAutoNamingRule& sf);
704 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
705 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
706 std::istream& operator>>(std::istream& o, ARDOUR::PFLPosition& sf);
707 std::istream& operator>>(std::istream& o, ARDOUR::AFLPosition& sf);
708 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
709 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
710 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
711 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
712 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
713 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
714 std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
715 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
716 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
717 std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf);
718 std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf);
719 std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var);
720 std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf);
721 std::istream& operator>>(std::istream& o, ARDOUR::MeterType& sf);
722
723 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
724 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
725 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
726 std::ostream& operator<<(std::ostream& o, const ARDOUR::TracksAutoNamingRule& sf);
727 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
728 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
729 std::ostream& operator<<(std::ostream& o, const ARDOUR::PFLPosition& sf);
730 std::ostream& operator<<(std::ostream& o, const ARDOUR::AFLPosition& sf);
731 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
732 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
733 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
734 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
735 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
736 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
737 std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
738 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
739 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
740 std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf);
741 std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf);
742 std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var);
743 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf);
744 std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterType& sf);
745
746 /* because these operators work on types which can be used when making
747    a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported.
748 */
749 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
750 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
751 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::VUMeterStandard& sf);
752 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::MeterLineUp& sf);
753
754 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
755 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
756 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::VUMeterStandard& sf);
757 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterLineUp& sf);
758
759
760 static inline ARDOUR::framepos_t
761 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
762 {
763         long double result = (long double) session_frame * (long double) speed;
764
765         if (result >= (long double) ARDOUR::max_framepos) {
766                 return ARDOUR::max_framepos;
767         } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
768                 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
769         } else {
770                 return result;
771         }
772 }
773
774 static inline ARDOUR::framepos_t
775 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
776 {
777         /* NB - do we need a check for speed == 0 ??? */
778         long double result = (long double) track_frame / (long double) speed;
779
780         if (result >= (long double) ARDOUR::max_framepos) {
781                 return ARDOUR::max_framepos;
782         } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
783                 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
784         } else {
785                 return result;
786         }
787 }
788
789 /* for now, break the rules and use "using" to make this "global" */
790
791 using ARDOUR::framepos_t;
792
793
794 #endif /* __ardour_types_h__ */