edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiB29cb69fTahinli25 days ago1016 commits
| 1 | //! Syncing the cameras of a multicam clip by their sound. |
| 2 | //! |
| 3 | //! Every camera hears the same room, so the loudness curves of their tracks have the same shape, |
| 4 | //! shifted by the distance between the moments the cameras started rolling. [`best_lag`] finds |
| 5 | //! that shift by normalised cross-correlation of the two curves (the dB levels of |
| 6 | //! [`crate::silence::levels`], 50 a second, with the slow trend taken out), which is accurate to |
| 7 | //! one 20 ms window and needs no more than a clap, a voice or a song both cameras heard. |
| 8 | |
| 9 | use crateWINDOWS_PER_SEC; |
| 10 | |
| 11 | /// How much of each track's start is listened to, in seconds. |
| 12 | pub const SYNC_SECS: f64 = 240.0; |
| 13 | |
| 14 | /// The furthest apart two cameras' starts may be, in seconds. |
| 15 | pub const MAX_LAG_SECS: f64 = 120.0; |
| 16 | |
| 17 | /// A match weaker than this normalised correlation is not believed. |
| 18 | pub const MIN_SCORE: f32 = 0.2; |
| 19 | |
| 20 | /// The shortest overlap, in seconds, a lag is judged on. |
| 21 | const MIN_OVERLAP_SECS: f64 = 3.0; |
| 22 | |
| 23 | /// The lowest level that counts, in dB: below it a track is silence. |
| 24 | const FLOOR_DB: f32 = -70.0; |
| 25 | |
| 26 | /// Where `other` sits against `reference`. |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | /// The loudness curve with its trend (a one-second running mean) removed and silence clamped, so |
| 37 | /// that only the events are left to match. |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// The lag of `other` against `reference`, both loudness curves in dB at [`WINDOWS_PER_SEC`], within |
| 54 | /// `max_lag_secs`. `None` when either is too short or silent to judge. |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 |