Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hingobway committed Nov 20, 2024
1 parent 720c854 commit a42a988
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 110 deletions.
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,50 @@

![wavslice mockups](https://github.com/user-attachments/assets/de4fbccf-ff67-42b2-8cb8-e52169cd9c2e)

### building manually
Embed markers from your favorite DAW into audio files, particularly for use with QLab slices.

the app is currently reliably tested only on arm64 macOS.
## download

dependencies:
The app is prebuilt for apple silicon [here](https://github.com/hingobway/wavslice/releases), but it is currently unsigned. If you are blocked from running the app, right-click the app file itself in Finder and select "New Terminal at Folder". Then run

- C/C++ (`xcode-select --install`)
- [pnpm](pnpm.io)
- [rust](rust-lang.org)
```
xattr -dr com.apple.quarantine .
```

It should now run normally.

## Building

You'll need the following software to build the app:

- C/C++ build tools (XCode/Visual Studio)
- [git](git-scm.com)
- [cmake](cmake.org)
- [rust](rust-lang.org)
- [node](nodejs.org)
- [pnpm](pnpm.io)
- [homebrew](brew.sh) (macOS - strongly recommended)

### Auto build script (macOS)

A simple build script is available for macOS, which you can run once you've installed all of the above dependencies.

```
$ curl -fsSL https://h-n.me/install_wavslice | bash
```

The script will download and build the codebase for you. The app will be placed wherever you run the command.

### manual build instructions

this repository uses submodules for some C++ dependencies. after cloning, run this command to download dependencies:

```sh
$ git submodule update --init
```

You'll also need [libsndfile](https://github.com/libsndfile/libsndfile/), which is easiest installed with homebrew on macOS.

build C++ code using:

```sh
Expand Down
54 changes: 54 additions & 0 deletions build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -e

# CHECK DEPS

echo
echo "CHECKING DEPENDENCIES..."
echo

brew --version > /dev/null
git --version > /dev/null
clang --version > /dev/null
cmake --version > /dev/null
rustc --version > /dev/null
node --version > /dev/null
pnpm --version > /dev/null

echo DONE.


# INSTALL

echo
echo "DOWNLOADING..."
echo


git clone https://github.com/hingobway/wavslice.git .WAVSLICETMP
cd .WAVSLICETMP

git submodule update --init
brew install libsndfile
pnpm install

echo DONE.

echo
echo "INSTALLING..."
echo

cd src-cpp
cmake -Bbuild
cmake --build build --config Release
cd ..

pnpm tauri build --bundles app

mv src-tauri/target/release/bundle/macos/*.app ..
cd ..
rm -rf .WAVSLICETMP

echo
echo "DONE!"
echo
39 changes: 15 additions & 24 deletions src-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,32 @@ set(PROGRAM_NAME "markers")
find_package(SndFile CONFIG REQUIRED)
include(include/midifile.cmake)

# FIND CORRECT BINARY NAME
if(APPLE)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(PROC "aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(PROC "x86_64")
else()
set(PROC "unknown")
endif()

set(TARGET_NAME "${PROGRAM_NAME}-${PROC}-apple-darwin")
# DETERMINE TARGET TRIPLET FOR RUST
execute_process(
COMMAND rustc "-Vv"
OUTPUT_VARIABLE RUST_HOST
)

if(${RUST_HOST} MATCHES "host: ([^ \t\r\n]+)")
set(RUST_HOST ${CMAKE_MATCH_1})
else()
set(TARGET_NAME ${PROGRAM_NAME})
message(WARNING "Only CLI functionality is available on non MacOS platforms.")
message(FATAL_ERROR "Failed to determine rust-compatible host name for this machine. Make sure you have installed rust and that the rustc command-line tool is accessible.")
endif()

# PREP TARGET
set(TARGET_NAME "${PROGRAM_NAME}-${RUST_HOST}")
add_executable(${TARGET_NAME})
target_compile_options(${TARGET_NAME} PRIVATE -Wall)

set_target_properties(${TARGET_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../src-tauri/bin"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../src-tauri/bin"
)

# ADD FILES
file(GLOB_RECURSE HEADER_FILES src/*.hpp)
target_sources(${TARGET_NAME}
PRIVATE
${HEADER_FILES}

src/main.cpp
src/audio.cpp
src/midi.cpp
src/utils.cpp
)
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})

# LINK LIBRARIES
target_link_libraries(${TARGET_NAME}
Expand Down
2 changes: 1 addition & 1 deletion src-cpp/src/audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ namespace AUDIO

int readMarkers(const char *file_path);
int readAudioSampleRate(const char *file_path);
}
}
2 changes: 1 addition & 1 deletion src-cpp/src/midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ int MIDI::readMarkers(const char *file_path, int SR)
std::cout << "MARKERS " << mstring.str() << std::endl;

return 0;
}
}
3 changes: 1 addition & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "tauri_app_lib"
name = "wavslice_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[build-dependencies]
Expand All @@ -23,4 +23,3 @@ tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-dialog = "2"

2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
tauri_app_lib::run()
wavslice_lib::run()
}
2 changes: 1 addition & 1 deletion src-tsx/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function App() {

return (
<>
<div className="flex min-h-dvh flex-col gap-2 p-2 pt-0">
<div className="fixed inset-0 flex flex-col gap-2 p-2 pt-0">
{/* header */}
<Header />

Expand Down
47 changes: 26 additions & 21 deletions src-tsx/components/FileSave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
useInputFileObjects,
useMarkersList,
} from '@/ctx/fileDrop';
import { writeAudioFile } from '@/func/rpc';
import { writeAudioFile } from '@/rpc/commands';
import { useLoading } from '@/utils/transition';
import { Transition } from '@headlessui/react';
import { save } from '@tauri-apps/plugin-dialog';
import clsx from 'clsx';
Expand All @@ -17,7 +18,6 @@ export default function FileSave() {
const markers = useMarkersList();
const reset = useFullReset();

const [isLoading, setIsLoading] = useState(false);
const [status, setStatus] = useState<'SUCCESS' | 'ERROR' | null>(null);
useEffect(() => {
let tm: ReturnType<typeof setTimeout>;
Expand All @@ -26,29 +26,34 @@ export default function FileSave() {
return () => clearTimeout(tm);
}, [status]);

const [isLoading, loading] = useLoading();

// handle save
const submit = useCallback(async () => {
setIsLoading(true);
const submit = useCallback(() => {
loading(async () => {
if (!files.audio) return;

if (!files.audio) return;
// prompt output path
const outputFile = await save({
title: 'Save output audio file:',
defaultPath: files.audio?.path,
filters: [
{
name: 'allowed',
extensions: ['wav'],
},
],
});
if (!outputFile) return;
const success = await writeAudioFile(
files.audio.path,
outputFile,
markers,
);

// prompt output path
const outputFile = await save({
title: 'Save output audio file:',
defaultPath: files.audio?.path,
filters: [
{
name: 'allowed',
extensions: ['wav'],
},
],
setStatus(success ? 'SUCCESS' : 'ERROR');
if (success) reset();
});
if (!outputFile) return;
const success = await writeAudioFile(files.audio.path, outputFile, markers);

setStatus(success ? 'SUCCESS' : 'ERROR');
if (success) reset();
setIsLoading(false);
}, [files.audio, markers]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src-tsx/ctx/fileDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import MIME from 'mime/lite';
import { useCallback } from 'react';
import { readAudioFile, readMidiFile } from '@/func/rpc';
import { readAudioFile, readMidiFile } from '@/rpc/commands';

export const MAX_MARKERS = 100;

Expand Down
2 changes: 1 addition & 1 deletion src-tsx/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
@tailwind utilities;

body {
@apply cursor-default select-none bg-zinc-900 font-sans text-zinc-100;
@apply cursor-default select-none overflow-hidden bg-zinc-900 font-sans text-zinc-100;
}
Loading

0 comments on commit a42a988

Please sign in to comment.