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