Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@
</div>

<div class="flex gap-2 justify-center items-center">
<div class="flex gap-2 items-center">
<label for="offsetInput" class="text-zinc-300 text-sm">
Offset (ms):
</label>
<input
type="number"
id="offsetInput"
class="w-24 h-8 bg-zinc-800 text-zinc-100 border-2 border-zinc-700 rounded-lg px-2 text-center outline-none focus:border-orange-400 transition-all"
value="0"
step="10"
/>
</div>
<input type="file" name="lrcFileInput" id="lrcFile" class="hidden" accept=".lrc" />
<label
for="lrcFile"
Expand Down
7 changes: 5 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const charByCharCheckbox = document.getElementById('isCharByChar')
const duetCheckbox = document.getElementById('isDuet')
const switchVocalistBtn = document.getElementById('switchVocalistBtn')
const wordEndBtn = document.getElementById('wordEndBtn')
const offsetInput = document.getElementById('offsetInput')
let isWordByWord = wordByWordCheckbox.checked
let isCharByChar = charByCharCheckbox.checked
let isDuet = duetCheckbox.checked
Expand Down Expand Up @@ -531,7 +532,8 @@ function wordEnd() {
const lineEl = itemsList[currentItemIndex].children[0]
const wordEl = lineEl.children[currentWordIndex]
if (typeof wordEl?.dataset?.beginTime == 'undefined') return
const currentTime = wavesurfer.getCurrentTime()
const offset = Number(offsetInput.value) / 1000
const currentTime = Math.max(0, wavesurfer.getCurrentTime() + offset)
wordEl.dataset.endTime = currentTime
wordEl.classList.add('active')
if (currentWordIndex + 1 >= lineEl.childElementCount) {
Expand All @@ -555,7 +557,8 @@ function wordEnd() {
}

function next() {
const currentTime = wavesurfer.getCurrentTime()
const offset = Number(offsetInput.value) / 1000
const currentTime = Math.max(0, wavesurfer.getCurrentTime() + offset)
if (isWordByWord) {
// First item is not selected yet
if (currentItemIndex == -1) {
Expand Down