Changeset 6716 for trunk/liquidsoap/src/tools/mutils.ml
- Timestamp:
- 07/02/09 13:37:13 (14 months ago)
- Files:
-
- 1 copied
-
trunk/liquidsoap/src/tools/mutils.ml (copied) (copied from trunk/liquidsoap/src/tools/sutils.ml) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/liquidsoap/src/tools/mutils.ml
r6344 r6716 21 21 *****************************************************************************) 22 22 23 let lin_of_dB x = 10. ** (x /. 20.) 23 (** Convert a value into a channel number, checking that it actually exists. *) 24 let to_chan v = 25 let n = Lang.to_int v in 26 if n >= Fmt.midi_channels () then 27 raise (Lang.Invalid_value (v, "channel number too big (try increasing lang.midi.channels)")) 28 else 29 n 24 30 25 let dB_of_lin x = 20. *. log x /. log 10. 26 27 let clip x = min 1. (max (-.1.) x) 31 (** Convert delta-times to ticks. *) 32 let ticks_of_delta division tempo delta = 33 match division with 34 | Midi.Ticks_per_quarter tpq -> 35 (* These computations sometimes overflow on 32 bits. *) 36 let tpq = Int64.of_int tpq in 37 let tempo = Int64.of_int tempo in 38 let tps = Int64.of_int (Fmt.ticks_per_second ()) in 39 let ten = Int64.of_int 1000000 in 40 let delta = Int64.of_int delta in 41 let ( * ) = Int64.mul in 42 let ( / ) = Int64.div in 43 Int64.to_int ((((delta * tempo) / tpq) * tps) / ten) 44 | Midi.SMPTE (fps,res) -> 45 (delta * Fmt.ticks_per_second ()) / (fps * res)
