redesign VCA control over gain (and theoretically other scalar controls)
[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 LocaleMode {
253                 SET_LC_ALL,
254                 SET_LC_MESSAGES,
255                 SET_LC_MESSAGES_AND_LC_NUMERIC
256         };
257
258         enum RoundMode {
259                 RoundDownMaybe  = -2,  ///< Round down only if necessary
260                 RoundDownAlways = -1,  ///< Always round down, even if on a division
261                 RoundNearest    = 0,   ///< Round to nearest
262                 RoundUpAlways   = 1,   ///< Always round up, even if on a division
263                 RoundUpMaybe    = 2    ///< Round up only if necessary
264         };
265
266         class AnyTime {
267         public:
268                 enum Type {
269                         Timecode,
270                         BBT,
271                         Frames,
272                         Seconds
273                 };
274
275                 Type type;
276
277                 Timecode::Time     timecode;
278                 Timecode::BBT_Time bbt;
279
280                 union {
281                         framecnt_t     frames;
282                         double         seconds;
283                 };
284
285                 AnyTime() { type = Frames; frames = 0; }
286
287                 bool operator== (AnyTime const & other) const {
288                         if (type != other.type) { return false; }
289
290                         switch (type) {
291                           case Timecode:
292                                 return timecode == other.timecode;
293                           case BBT:
294                                 return bbt == other.bbt;
295                           case Frames:
296                                 return frames == other.frames;
297                           case Seconds:
298                                 return seconds == other.seconds;
299                         }
300                         return false; // get rid of warning
301                 }
302
303                 bool not_zero() const
304                 {
305                         switch (type) {
306                           case Timecode:
307                                 return timecode.hours != 0 || timecode.minutes != 0 ||
308                                        timecode.seconds != 0 || timecode.frames != 0;
309                           case BBT:
310                                 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
311                           case Frames:
312                                 return frames != 0;
313                           case Seconds:
314                                 return seconds != 0;
315                         }
316
317                         abort(); /* NOTREACHED */
318                         return false;
319                 }
320         };
321
322         /* used for translating audio frames to an exact musical position using a note divisor.
323            an exact musical position almost never falls exactly on an audio frame, but for sub-sample
324            musical accuracy we need to derive exact musical locations from a frame position
325            the division follows TempoMap::exact_beat_at_frame().
326            division
327            -1       musical location is the bar closest to frame
328             0       musical location is the musical position of the frame
329             1       musical location is the BBT beat closest to frame
330             n       musical location is the quarter-note division n closest to frame
331         */
332         struct MusicFrame {
333                 framepos_t frame;
334                 int32_t    division;
335
336                 MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {}
337
338                 void set (framepos_t f, int32_t d) {frame = f; division = d; }
339
340                 MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); }
341         };
342
343         /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
344            but this has a uint32_t id which Evoral::Range<> does not.
345         */
346         struct AudioRange {
347                 framepos_t start;
348                 framepos_t end;
349                 uint32_t id;
350
351                 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
352
353                 framecnt_t length() const { return end - start + 1; }
354
355                 bool operator== (const AudioRange& other) const {
356                         return start == other.start && end == other.end && id == other.id;
357                 }
358
359                 bool equal (const AudioRange& other) const {
360                         return start == other.start && end == other.end;
361                 }
362
363                 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
364                         return Evoral::coverage (start, end, s, e);
365                 }
366         };
367
368         struct MusicRange {
369                 Timecode::BBT_Time start;
370                 Timecode::BBT_Time end;
371                 uint32_t id;
372
373                 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
374                         : start (s), end (e), id (i) {}
375
376                 bool operator== (const MusicRange& other) const {
377                         return start == other.start && end == other.end && id == other.id;
378                 }
379
380                 bool equal (const MusicRange& other) const {
381                         return start == other.start && end == other.end;
382                 }
383         };
384
385         /*
386             Slowest = 6.6dB/sec falloff at update rate of 40ms
387             Slow    = 6.8dB/sec falloff at update rate of 40ms
388         */
389
390         enum MeterFalloff {
391                 MeterFalloffOff = 0,
392                 MeterFalloffSlowest = 1,
393                 MeterFalloffSlow = 2,
394                 MeterFalloffSlowish = 3,
395                 MeterFalloffModerate = 4,
396                 MeterFalloffMedium = 5,
397                 MeterFalloffFast = 6,
398                 MeterFalloffFaster = 7,
399                 MeterFalloffFastest = 8,
400         };
401
402         enum MeterHold {
403                 MeterHoldOff = 0,
404                 MeterHoldShort = 40,
405                 MeterHoldMedium = 100,
406                 MeterHoldLong = 200
407         };
408
409         enum EditMode {
410                 Slide,
411                 Splice,
412                 Ripple,
413                 Lock
414         };
415
416         enum RegionSelectionAfterSplit {
417                 None = 0,
418                 NewlyCreatedLeft = 1,  // bit 0
419                 NewlyCreatedRight = 2, // bit 1
420                 NewlyCreatedBoth = 3,
421                 Existing = 4,          // bit 2
422                 ExistingNewlyCreatedLeft = 5,
423                 ExistingNewlyCreatedRight = 6,
424                 ExistingNewlyCreatedBoth = 7
425         };
426
427         enum RegionPoint {
428                 Start,
429                 End,
430                 SyncPoint
431         };
432
433         enum Placement {
434                 PreFader,
435                 PostFader
436         };
437
438         enum MonitorModel {
439                 HardwareMonitoring, ///< JACK does monitoring
440                 SoftwareMonitoring, ///< Ardour does monitoring
441                 ExternalMonitoring  ///< we leave monitoring to the audio hardware
442         };
443
444         enum MonitorChoice {
445                 MonitorAuto = 0,
446                 MonitorInput = 0x1,
447                 MonitorDisk = 0x2,
448                 MonitorCue = 0x4,
449         };
450
451         enum MonitorState {
452                 MonitoringSilence = 0x1,
453                 MonitoringInput = 0x2,
454                 MonitoringDisk = 0x4,
455         };
456
457         enum MeterState {
458                 MeteringInput, ///< meter the input IO, regardless of what is going through the route
459                 MeteringRoute  ///< meter what is going through the route
460         };
461
462         enum VUMeterStandard {
463                 MeteringVUfrench,   // 0VU = -2dBu
464                 MeteringVUamerican, // 0VU =  0dBu
465                 MeteringVUstandard, // 0VU = +4dBu
466                 MeteringVUeight     // 0VU = +8dBu
467         };
468
469         enum MeterLineUp {
470                 MeteringLineUp24,
471                 MeteringLineUp20,
472                 MeteringLineUp18,
473                 MeteringLineUp15
474         };
475
476         enum PFLPosition {
477                 /** PFL signals come from before pre-fader processors */
478                 PFLFromBeforeProcessors,
479                 /** PFL signals come pre-fader but after pre-fader processors */
480                 PFLFromAfterProcessors
481         };
482
483         enum AFLPosition {
484                 /** AFL signals come post-fader and before post-fader processors */
485                 AFLFromBeforeProcessors,
486                 /** AFL signals come post-fader but after post-fader processors */
487                 AFLFromAfterProcessors
488         };
489
490         enum DenormalModel {
491                 DenormalNone,
492                 DenormalFTZ,
493                 DenormalDAZ,
494                 DenormalFTZDAZ
495         };
496
497         enum LayerModel {
498                 LaterHigher,
499                 Manual
500         };
501
502         enum ListenPosition {
503                 AfterFaderListen,
504                 PreFaderListen
505         };
506
507         enum AutoConnectOption {
508                 ManualConnect = 0x0,
509                 AutoConnectPhysical = 0x1,
510                 AutoConnectMaster = 0x2
511         };
512
513     enum TracksAutoNamingRule {
514         UseDefaultNames = 0x1,
515         NameAfterDriver = 0x2
516     };
517
518         enum SampleFormat {
519                 FormatFloat = 0,
520                 FormatInt24,
521                 FormatInt16
522         };
523
524         int format_data_width (ARDOUR::SampleFormat);
525
526         enum CDMarkerFormat {
527                 CDMarkerNone,
528                 CDMarkerCUE,
529                 CDMarkerTOC,
530                 MP4Chaps
531         };
532
533         enum HeaderFormat {
534                 BWF,
535                 WAVE,
536                 WAVE64,
537                 CAF,
538                 AIFF,
539                 iXML,
540                 RF64,
541                 RF64_WAV,
542                 MBWF,
543         };
544
545         struct PeakData {
546                 typedef Sample PeakDatum;
547
548                 PeakDatum min;
549                 PeakDatum max;
550         };
551
552         enum RunContext {
553                 ButlerContext = 0,
554                 TransportContext,
555                 ExportContext
556         };
557
558         enum SyncSource {
559                 /* These are "synonyms". It is important for JACK to be first
560                    both here and in enums.cc, so that the string "JACK" is
561                    correctly recognized in older session and preference files.
562                 */
563                 JACK = 0,
564                 Engine = 0,
565                 MTC,
566                 MIDIClock,
567                 LTC
568         };
569
570         enum ShuttleBehaviour {
571                 Sprung,
572                 Wheel
573         };
574
575         enum ShuttleUnits {
576                 Percentage,
577                 Semitones
578         };
579
580         typedef std::vector<boost::shared_ptr<Source> > SourceList;
581
582         enum SrcQuality {
583                 SrcBest,
584                 SrcGood,
585                 SrcQuick,
586                 SrcFast,
587                 SrcFastest
588         };
589
590         typedef std::list<framepos_t> AnalysisFeatureList;
591
592         typedef std::list<boost::shared_ptr<Route> > RouteList;
593         typedef std::list<boost::shared_ptr<Stripable> > StripableList;
594         typedef std::list<boost::weak_ptr  <Route> > WeakRouteList;
595         typedef std::list<boost::weak_ptr  <Stripable> > WeakStripableList;
596         typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
597
598         typedef std::list<boost::shared_ptr<VCA> > VCAList;
599
600         class Bundle;
601         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
602
603         enum WaveformScale {
604                 Linear,
605                 Logarithmic
606         };
607
608         enum WaveformShape {
609                 Traditional,
610                 Rectified
611         };
612
613         struct CleanupReport {
614                 std::vector<std::string> paths;
615                 size_t                   space;
616         };
617
618         enum PositionLockStyle {
619                 AudioTime,
620                 MusicTime
621         };
622
623         /** A struct used to describe changes to processors in a route.
624          *  This is useful because objects that respond to a change in processors
625          *  can optimise what work they do based on details of what has changed.
626         */
627         struct RouteProcessorChange {
628                 enum Type {
629                         GeneralChange = 0x0,
630                         MeterPointChange = 0x1,
631                         RealTimeChange = 0x2
632                 };
633
634                 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
635                 {}
636
637                 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
638                 {}
639
640                 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
641                 {}
642
643                 /** type of change; "GeneralChange" means anything could have changed */
644                 Type type;
645                 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
646                 bool meter_visibly_changed;
647         };
648
649         struct BusProfile {
650                 AutoConnectOption input_ac;      /* override the RC config for input auto-connection */
651                 AutoConnectOption output_ac;     /* override the RC config for output auto-connection */
652                 uint32_t master_out_channels;    /* how many channels for the master bus */
653                 uint32_t requested_physical_in;  /* now many of the available physical inputs to consider usable */
654                 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
655         };
656
657         enum FadeShape {
658                 FadeLinear,
659                 FadeFast,
660                 FadeSlow,
661                 FadeConstantPower,
662                 FadeSymmetric,
663         };
664
665         enum TransportState {
666                 /* these values happen to match the constants used by JACK but
667                    this equality cannot be assumed.
668                 */
669                 TransportStopped = 0,
670                 TransportRolling = 1,
671                 TransportLooping = 2,
672                 TransportStarting = 3,
673         };
674
675         enum PortFlags {
676                 /* these values happen to match the constants used by JACK but
677                    this equality cannot be assumed.
678                 */
679                 IsInput = 0x1,
680                 IsOutput = 0x2,
681                 IsPhysical = 0x4,
682                 CanMonitor = 0x8,
683                 IsTerminal = 0x10,
684
685                 /* non-JACK related flags */
686                 Hidden = 0x20,
687                 Shadow = 0x40
688         };
689
690         enum MidiPortFlags {
691                 MidiPortMusic = 0x1,
692                 MidiPortControl = 0x2,
693                 MidiPortSelection = 0x4,
694                 MidiPortVirtual = 0x8
695         };
696
697         struct LatencyRange {
698             uint32_t min; //< samples
699             uint32_t max; //< samples
700         };
701
702         enum BufferingPreset {
703                 Small,
704                 Medium,
705                 Large,
706                 Custom,
707         };
708
709         enum AutoReturnTarget {
710                 LastLocate = 0x1,
711                 RangeSelectionStart = 0x2,
712                 Loop = 0x4,
713                 RegionSelectionStart = 0x8,
714         };
715
716         enum PlaylistDisposition {
717                 CopyPlaylist,
718                 NewPlaylist,
719                 SharePlaylist
720         };
721
722         enum MidiTrackNameSource {
723                 SMFTrackNumber,
724                 SMFTrackName,
725                 SMFInstrumentName
726         };
727
728         enum MidiTempoMapDisposition {
729                 SMFTempoIgnore,
730                 SMFTempoUse,
731         };
732
733 } // namespace ARDOUR
734
735
736 /* these cover types declared above in this header. See enums.cc
737    for the definitions.
738 */
739 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
740 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
741 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
742 std::istream& operator>>(std::istream& o, ARDOUR::TracksAutoNamingRule& sf);
743 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
744 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
745 std::istream& operator>>(std::istream& o, ARDOUR::MonitorChoice& sf);
746 std::istream& operator>>(std::istream& o, ARDOUR::PFLPosition& sf);
747 std::istream& operator>>(std::istream& o, ARDOUR::AFLPosition& sf);
748 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
749 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
750 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
751 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
752 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
753 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
754 std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
755 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
756 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
757 std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf);
758 std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf);
759 std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var);
760 std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf);
761 std::istream& operator>>(std::istream& o, ARDOUR::MeterType& sf);
762
763 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
764 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
765 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
766 std::ostream& operator<<(std::ostream& o, const ARDOUR::TracksAutoNamingRule& sf);
767 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
768 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
769 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorChoice& sf);
770 std::ostream& operator<<(std::ostream& o, const ARDOUR::PFLPosition& sf);
771 std::ostream& operator<<(std::ostream& o, const ARDOUR::AFLPosition& sf);
772 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
773 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
774 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
775 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
776 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
777 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
778 std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
779 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
780 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
781 std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf);
782 std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf);
783 std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var);
784 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf);
785 std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterType& sf);
786
787 /* because these operators work on types which can be used when making
788    a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported.
789 */
790 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
791 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
792 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::VUMeterStandard& sf);
793 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::MeterLineUp& sf);
794 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::LocaleMode& sf);
795
796 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
797 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
798 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::VUMeterStandard& sf);
799 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterLineUp& sf);
800 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::LocaleMode& sf);
801
802
803 static inline ARDOUR::framepos_t
804 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
805 {
806         long double result = (long double) session_frame * (long double) speed;
807
808         if (result >= (long double) ARDOUR::max_framepos) {
809                 return ARDOUR::max_framepos;
810         } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
811                 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
812         } else {
813                 return result;
814         }
815 }
816
817 static inline ARDOUR::framepos_t
818 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
819 {
820         /* NB - do we need a check for speed == 0 ??? */
821         long double result = (long double) track_frame / (long double) speed;
822
823         if (result >= (long double) ARDOUR::max_framepos) {
824                 return ARDOUR::max_framepos;
825         } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
826                 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
827         } else {
828                 return result;
829         }
830 }
831
832 /* for now, break the rules and use "using" to make this "global" */
833
834 using ARDOUR::framepos_t;
835
836
837 #endif /* __ardour_types_h__ */