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