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