Skip to content

Commit

Permalink
Vendor demucs.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sevagh committed Jan 2, 2024
1 parent f8bd6a4 commit bfc5dc3
Show file tree
Hide file tree
Showing 25 changed files with 120 additions and 4,897 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
path = vendor/demucs
url = https://github.com/sevagh/demucs
branch = release_v4
[submodule "vendor/demucs.cpp"]
path = vendor/demucs.cpp
url = https://github.com/sevagh/demucs.cpp
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -flto -msimd128 -fno-exceptions -fno-signed-zeros -fassociative-math -freciprocal-math -fno-math-errno -fno-rounding-math -fno-signaling-nans -funsafe-math-optimizations -fno-trapping-math -fno-rtti -DNDEBUG")

# Add Eigen3 include directory
include_directories(vendor/eigen)
# Add Eigen3 and demucs.cpp include directory
include_directories(vendor/eigen vendor/demucs.cpp/src)

# Check if the build is for Emscripten
if(NOT EMSCRIPTEN)
Expand All @@ -24,9 +24,8 @@ endif()
set(COMMON_LINK_FLAGS "-flto -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s MODULARIZE=1 -s 'EXPORTED_RUNTIME_METHODS=[\"FS\"]'")

# demucs executable
file(GLOB DEMUCS_SOURCES "src-demucs/*.cpp" "src-demucs/wasm_glue.cpp")
file(GLOB DEMUCS_SOURCES "vendor/demucs.cpp/src/*.cpp" "src/wasm_glue.cpp")
add_executable(demucs ${DEMUCS_SOURCES})
target_include_directories(demucs PRIVATE src-demucs) # Include src-demucs only for demucs target
set_target_properties(demucs PROPERTIES
LINK_FLAGS "${COMMON_LINK_FLAGS} -s EXPORT_NAME='libdemucs' -s EXPORTED_FUNCTIONS=\"['_malloc', '_free', '_modelInit', '_modelLoadProgress', '_modelInferenceProgress', '_modelDemixSegment']\""
)
Expand Down
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ When the demixing is complete, you can download the following stems in wav files
- Drums
- Melody (catchall for non-bass/drums/vocals - also called 'other' in music demixing research)
- Vocals
- Karaoke (bass + drums + melody)
- Instrumental (bass + drums + melody)

## Technical implementation

Expand Down
82 changes: 79 additions & 3 deletions docs/assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ blockquote {
}

#sign-up {
color: #ffffff;
color: black;
background-color: #3cb371;
box-shadow: 0 4px #276324;
}
Expand Down Expand Up @@ -739,6 +739,82 @@ blockquote {
margin-right: 10px;
}

#zip-progress-bar-batch {
background-color: #2a9cbe; /* Different color for zip progress bar */
.sticky-banner {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #88ab75; /* Green background */
color: black; /* White text */
z-index: 5; /* Higher than other content */
box-shadow: 0 -2px 5px rgba(0,0,0,0.2); /* Optional shadow for depth */
}

.banner-content {
display: flex;
//justify-content: space-between;
align-items: center;
padding: 5px;
max-width: 1000px; /* Adjust as needed */
margin: 0 auto; /* Center content if banner is not full width */
justify-content: center;
padding: 5px; /* Reduced padding */
}

.banner-content > * {
margin: 0 10px; /* Adjust space between elements */
}

/* Additional styling for your image, text, and buttons */
.banner-button-signup {
display: inline-flex; /* Use flexbox for inline layout */
flex-direction: column; /* Stack children vertically */
align-items: flex-start; /* Align text to the left */
justify-content: center; /* Center vertically */
text-align: left; /* Left-align text within flex items */
display: inline-block; /* Allows padding and width/height if needed */
text-decoration: none; /* Removes underline from links */
background-color: #f5f5dc; /* Bootstrap primary blue */
color: black;
padding: 10px 20px;
border-radius: 5px;
box-shadow: 0 4px #d2d2a4;
transition: background-color 0.3s, transform 0.3s;
cursor: pointer; /* Cursor indicates it's clickable */
}

.banner-button-signup:hover {
background-color: #ebe8d4; /* Slightly darker blue on hover */
transform: translateY(-2px);
}
.banner-button-signup:active {
transform: translateY(1px);
box-shadow: 0 1px #d2d2a4;
}

.banner-dismiss-button {
display: inline-flex; /* Use flexbox for inline layout */
flex-direction: column; /* Stack children vertically */
align-items: flex-start; /* Align text to the left */
justify-content: center; /* Center vertically */
text-align: left; /* Left-align text within flex items */
display: inline-block; /* Allows padding and width/height if needed */
background-color: #c0c0c0; /* Soft red color */
text-decoration: none;
color: black;
padding: 10px 20px;
border-radius: 5px;
box-shadow: 0 4px #a8a8a8;
transition: background-color 0.3s, transform 0.3s;
cursor: pointer;
}

.banner-dismiss-button:hover {
background-color: #b0b0b0; /* Lighter red on hover */
transform: translateY(-2px);
}

.banner-dismiss-button:active {
transform: translateY(1px);
box-shadow: 0 1px #a8a8a8;
}
2 changes: 1 addition & 1 deletion docs/demucs.js

Large diffs are not rendered by default.

Binary file modified docs/demucs.wasm
Binary file not shown.
10 changes: 9 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ description: "Split songs, demix music, and separate stems with our AI-based too
<script src="main.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/umd/index.js"></script>

<div id="sticky-banner" class="sticky-banner" style="display: none;">
<div class="banner-content">
Get news and sneak previews of upcoming features!
<a href="https://docs.google.com/forms/d/e/1FAIpQLSek_QU_BGd7CL2BLVOLDs7JmTZzcLKJiK5k4ysxoCEMjEGrtA/viewform?usp=sf_link" class="banner-button-signup" target="_blank">Sign up</a>
<button class="banner-dismiss-button" id="banner-dismiss-button">Dismiss</button>
</div>
</div>

# Free AI-powered music demixer

<a href="https://theresanaiforthat.com/ai/free-music-demixer/?ref=featured&v=691965" target="_blank"><img width="250" src="https://media.theresanaiforthat.com/featured3.png"></a>
<a href="https://theresanaiforthat.com/ai/free-music-demixer/?ref=featured&v=691965" target="_blank"><img width="250" src="https://media.theresanaiforthat.com/featured3.png" alt="theresanaiforthat-promo"></a>

In music demixing, music source separation, or song splitting, AI models are used to separate the different instruments from a music recording into stems. This web application allows you to demix or split your music files, free and with no usage limits since it runs on **your computer!** 🫵🏽

Expand Down
23 changes: 22 additions & 1 deletion docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function fetchAndCacheFiles(model) {
];

// Map each file to a fetch request and then process the response
const fetchPromises = filesToFetch.map(file =>
const fetchPromises = filesToFetch.map(file =>
fetch(file).then(response => {
if (!response.ok) {
throw new Error(`Failed to fetch ${file}`);
Expand Down Expand Up @@ -418,6 +418,10 @@ document.getElementById('load-waveform').addEventListener('click', () => {
const file = fileInput.files[0];
if (!file) {
writeJsLog('No file selected.');
document.getElementById('batch-upload').disabled = false;
document.getElementById('load-batch').disabled = false;
document.getElementById('audio-upload').disabled = false;
document.getElementById('load-waveform').disabled = false;
return;
}

Expand Down Expand Up @@ -719,6 +723,11 @@ document.addEventListener("DOMContentLoaded", function() {
// Initial update on page load
updateWorkerCount1();
updateWorkerCount2();

// check to see if pop banner should be shown
if (!sessionStorage.getItem('bannerDismissed')) {
document.getElementById('sticky-banner').style.display = 'block';
}
});

function clearLogs() {
Expand Down Expand Up @@ -779,6 +788,10 @@ document.getElementById('load-batch').addEventListener('click', async () => {
const files = inputDir.files;
if (!files) {
writeJsLog('No files in input folder.');
document.getElementById('batch-upload').disabled = false;
document.getElementById('load-batch').disabled = false;
document.getElementById('audio-upload').disabled = false;
document.getElementById('load-waveform').disabled = false;
return;
}

Expand Down Expand Up @@ -933,3 +946,11 @@ function packageAndZip(targetWaveforms, filename) {
zipLink.download = `${filename}_stems.zip`;
document.getElementById('output-links-batch').appendChild(zipLink);
}


document.getElementById('banner-dismiss-button').addEventListener('click', function() {
console.log("Setting bannerDismissed to true")
sessionStorage.setItem('bannerDismissed', 'true');
document.getElementById('sticky-banner').style.display = 'none';
console.log(sessionStorage.getItem('bannerDismissed'))
});
2 changes: 1 addition & 1 deletion docs/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const CACHE_NAME = "v20231230";
const CACHE_NAME = "v20240102";
const RESOURCES_TO_PRELOAD = [
"demucs.js",
"demucs.wasm",
Expand Down
Loading

0 comments on commit bfc5dc3

Please sign in to comment.