Skip to content

Commit

Permalink
tsme update
Browse files Browse the repository at this point in the history
  • Loading branch information
hingobway committed Dec 4, 2024
1 parent c4d866b commit 5b9c1a6
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 31 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@tauri-apps/plugin-fs": "~2",
"@tauri-apps/plugin-http": "~2",
"@tauri-apps/plugin-shell": "^2.0.1",
"@tauri-apps/plugin-upload": "~2",
"cheerio": "^1.0.0",
"clsx": "^2.1.1",
"csv-parse": "^5.6.0",
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions src-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ set(PROGRAM_NAME "markers")

# PACKAGE INCLUDE
find_package(SndFile CONFIG REQUIRED)
find_package(Boost CONFIG REQUIRED COMPONENTS locale)
include(include/midifile.cmake)

# find_package(Boost CONFIG REQUIRED COMPONENTS locale)

# DETERMINE TARGET TRIPLET FOR RUST
execute_process(
COMMAND rustc "-Vv"
Expand All @@ -32,15 +33,23 @@ set_target_properties(${TARGET_NAME} PROPERTIES
)

# ADD FILES
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")
target_sources(${TARGET_NAME} PRIVATE ${SOURCE_FILES})
# file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
# "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")
target_sources(${TARGET_NAME} PRIVATE
src/main.cpp
src/audio.cpp
src/midi.cpp
src/utils.cpp

# src/text.cpp
)

# LINK LIBRARIES
target_link_libraries(${TARGET_NAME}
PRIVATE
SndFile::sndfile
Boost::locale
midifile

# Boost::locale
)
5 changes: 3 additions & 2 deletions src-cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "utils.hpp"
#include "audio.hpp"
#include "midi.hpp"
#include "text.hpp"
// #include "text.hpp"

// ------------------------------------------------
// MAIN
Expand Down Expand Up @@ -86,7 +86,8 @@ int main(int argc, const char *argv[])
return argErr();
}

return TEXT::readMarkers(argv[2], sr);
// return TEXT::readMarkers(argv[2], sr);
(void)sr;

break;
}
Expand Down
3 changes: 2 additions & 1 deletion src-tsx/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export default function App() {
// ROUTING

if (location.pathname === TextFormatDialog.path) return <TextFormatDialog />;
if (location.pathname === RemoteSessionDialog.path) return <RemoteSessionDialog />;
if (location.pathname === RemoteSessionDialog.path)
return <RemoteSessionDialog />;

// RENDER

Expand Down
8 changes: 2 additions & 6 deletions src-tsx/components/FileDropState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
InputFiles,
useFileOnTop,
useInputFiles,
useMarkers,
useRemoteConfirm,
useUpdateMarkers,
} from '@/ctx/fileDrop';
Expand All @@ -29,7 +28,6 @@ export default function FileDropState({ children }: Children) {
const [, setOnTop] = useFileOnTop();

const [files, setFiles] = useInputFiles();
const [, setMarkers] = useMarkers();

const [, setConfirmed] = useRemoteConfirm();

Expand All @@ -45,6 +43,7 @@ export default function FileDropState({ children }: Children) {
if (fp.mime === ('text/plain' satisfies MimeType)) newFiles.text = path;
if (SESSION_FILE_EXTS.includes(fp.ext.toLowerCase())) {
newFiles.session = path;
setConfirmed(null);
RemoteSessionDialog.create();
}
}
Expand Down Expand Up @@ -93,10 +92,7 @@ export default function FileDropState({ children }: Children) {
evs.push(
ipcListen('remote_confirm')(({ payload: agreed }) => {
setConfirmed(agreed);
if (!agreed) {
setFiles((f) => ({ ...f, session: undefined }));
setMarkers((c) => ({ ...c, session: [] }));
}
if (!agreed) setFiles((f) => ({ ...f, session: undefined }));
}),
);

Expand Down
26 changes: 24 additions & 2 deletions src-tsx/components/MarkerRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ReactNode, useEffect } from 'react';

import { Check } from 'lucide-react';
import { Checkbox } from '@headlessui/react';
import { Markers, useSelectedMarkers } from '@/ctx/fileDrop';
import {
Markers,
useGlobalIsLoading,
useSelectedMarkers,
} from '@/ctx/fileDrop';
import { SetState } from '@/utils/reactTypes';

export default function MarkerRow({
Expand Down Expand Up @@ -34,6 +38,8 @@ export default function MarkerRow({
if (count) setChecked(true);
}, [count]);

const isLoading = useGlobalIsLoading();

return (
<>
<div
Expand All @@ -60,10 +66,26 @@ export default function MarkerRow({
className="group/m text-zinc-500 group-data-[e]:text-zinc-400"
data-w={(enabled && count) || null}
>
<span className="group-data-[w]/m:text-zinc-100">{count}</span>
{/* loading spinner */}
{isLoading && (
<>
<Spinner />
<span className="inline-block w-0.5"></span>
</>
)}
{/* count */}
{!isLoading && (
<span className="group-data-[w]/m:text-zinc-100">{count}</span>
)}
<span className=""> markers</span>
</div>
</div>
</>
);
}

function Spinner() {
return (
<div className="inline-block size-2 animate-spin rounded-full border border-zinc-500 border-t-transparent" />
);
}
13 changes: 11 additions & 2 deletions src-tsx/ctx/fileDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,22 @@ const selectedMarkersState = atom({
});
export const useSelectedMarkers = () => useRecoilState(selectedMarkersState);

const remoteConfirmState = atom({
const remoteConfirmState = atom<boolean | null>({
key: 'RemoteConfirm',
default: false,
default: null,
});
export const useRemoteConfirm = () => useRecoilState(remoteConfirmState);

const globalLoadingState = atom({
key: 'GlobalLoading',
default: false,
});
export const useGlobalIsLoading = () => useRecoilValue(globalLoadingState);

export const useUpdateMarkers = () => {
const cb = useRecoilCallback(({ snapshot, set }) => async () => {
set(globalLoadingState, true);

const files = await snapshot.getPromise(inputFilesState);
const remoteAllowed = await snapshot.getPromise(remoteConfirmState);

Expand Down Expand Up @@ -152,6 +160,7 @@ export const useUpdateMarkers = () => {

set(markersState, markers);
set(audioLengthState, audioLength);
set(globalLoadingState, false);
});
return cb;
};
Expand Down
2 changes: 1 addition & 1 deletion src-tsx/func/tsme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function getSessionMarkers(filepath: string, SR: number = 0) {
const formdata = new FormData();
formdata.append('file', new Blob([sessionFile]), fp.name);

// fetch timestamps
// upload session file
const resp = await fetch('https://timestamps.me/results', {
method: 'POST',
redirect: 'follow',
Expand Down

0 comments on commit 5b9c1a6

Please sign in to comment.