from Hacker News

Show HN: Mofi – Content-aware fill for audio to change a song to any duration

by jaflo on 6/26/23, 3:12 PM with 161 comments

I worked on a web service that allows you to import a song and define a target length that the song will be shortened or lengthened to. It does this by analyzing the song and finding repeating audio patterns. This is helpful for making any song match a video or performance with a set duration. You can also specify areas of the song to prefer or avoid. An example is available here: https://mofi.loud.red/edit/8bd3fdf780f8c3927e41029f3b957f8a7...

The cool thing is that after the song is analyzed on the server, the client can recompute and preview the results completely client-side through an implementation that uses Web Workers and WebAssembly. The audio previewing uses Tone.js. I am thinking of writing up some more details about the implementation in the future.

I'm still working on a way to explain this easily, but I like the idea of carrying over the concept of content-aware fill from images to audio.

Please let me know if you have any comments or questions!

  • by Philip-J-Fry on 6/26/23, 4:53 PM

    There used to be something called the eternal jukebox I think. But you could give it a song and it would endlessly loop the audio like you have here. But it would also switch it up and change the parts it looped. And it would have a nice visualisation showing how the parts of the song connect and the different paths it takes.

    I think it was https://eternalbox.dev/ since that's all I can find on Google. But that site is down.

  • by josuepeq on 6/26/23, 4:44 PM

    This is neat, I have wondered if anything of this nature existed, in the past, as a child of the 80s/90s attempting to master the art of the perfect mixtape… 30 minutes a side down to the second the tape runs out, would be a win.

    But for today’s music, shortening the 2010s/2020 already shorter lengths would mean a song might not be more than a minute in length. On average, full unedited tracks today end up being a bit shorter than they used to be, solely due to the economics of streaming. Rather than paying for the content second by second, it is done by paying per track play. The result is a lot of 2 minute tracks, which were produced with the “verse” parts getting jammed together into the “chorus” with no break in vocals, which also uses pitch adjustments, “the “bridge” is an afterthought that is terrible, or more recently, nonexistent……… Instrumental solo? Anyone? Bueller?

    Music is no longer anticipated, budgeted for, and purchased on launch day with great fanfare. We have grown accustomed to the idea that we should have everything available at our fingertips, and as a consequence of this we get exactly what we pay for.

  • by lelanthran on 6/26/23, 7:30 PM

    My word is this impressive.

    I uploaded Wuthering Heights[1], selected just the trailing guitar solo (3:09 to just before the fade-out starts), and got a bunch of seemless sounding 3m tracks of just that guitar shredding away.

    All the ones it generated were perfectly cut and pasted, with one exception in track 2 where I could tell where it was cut/pasted.

    Can't wait to try it with the guitar at the end of Brothers in Arms (Dire Straits), or the flute solo in Locomotive Breath.

    If anyone is looking for a good use of AI, I wouldn't mind a webpage that lets me say "complete this solo that was abruptly cut short" and get something great.

    [1] This one is especially sad because the sound engineer/producer later lamented that he faded the solo out so quickly because the player was still improving like mad and what he had left after the fadeout was apparently better than what he had done while recording.

  • by cheschire on 6/26/23, 4:39 PM

    There's a specific sect of deadmau5 fans that would love to use this to generate multi-hour continuous mixes of a song called Strobe.
  • by mmh0000 on 6/26/23, 5:35 PM

    This is the coolest thing ever!

    I like to have multiple hour continuations of songs which I use to help me fall asleep. In the past I've made my own, but I'm terrible at audio editing. It is a ton of work and, for me, really hard to get right.

    After a little bit of experimenting with Mofi, it seems to do a very good job and selecting when to repeat a sections.

    [edit]

    Here's my first attempt for a 30 minute song:

    https://mofi.loud.red/edit/ebbf4b410181aa767152945cbb6a2d679...

  • by mmh0000 on 6/26/23, 10:06 PM

    After spending all afternoon playing with this. I have two inputs.

    1] A lot of the heavy lifting is done client side, which is excellent; I have a super fast processor! But, watching the CPU utilization, it seems to spike the CPU for a few milliseconds, then waits for a second or two and, spikes the CPU again, then repeats. I suspect there may be some significant performance improvements to be had on client recomputes.

    2] While it is doing recomputes, it would be great to get a progress bar or, at least, a message saying, "This will take a long time, be patient." It took me multiple attempts to determine that the service was indeed working, just that my client was taking its sweet time recomputing.

  • by spaceman_2020 on 6/26/23, 3:50 PM

    Can’t wait to use this to stretch my 19 minute prog rock tracks into 190 minutes :)
  • by diggum on 6/26/23, 9:37 PM

    I was fortunate to help bring similar tech to life as a PM for Adobe Audition and Premiere Pro in a feature dubbed Remix. Since we were designing to help music fit the duration of a scene or video project, our goals resulted in a slightly different experience from those of music fans wanting to recut a song for general purpose listening, but it worked like magic for most tracks. Still one of my favorite projects that I worked on.
  • by Solvency on 6/26/23, 4:06 PM

    How did you make the animation in the homepage? It's definitely not a screen recording...it feels like something animated in After Effects at 60fps. Is that true? Or did you use something else?
  • by zedadex on 7/6/23, 2:32 PM

    As a fan of tools like this and Eternal Jukebox, I cannot wait for the ones that have an option to request a cut specifically, like "from approximately this point, jump back to around this other point", while using the 'smart' features to line up the audio cuts (I'm sure stuff like that is built into the CC suite but I'm not springing that kind of money to recut a few of my tunes for personal listening ).

    With Eternal Jukebox I was able to emulate it by setting the jump percent very high manually at the right time (but had to be paying attention + had to get lucky with which branch it took), whereas here I'll see if I can get it going by calculating what the cut I want would set the song length to, and requesting that length and fewest cuts. (Edit: didn't work)

    Sometimes the simplest features are the easiest to overlook but most useful

  • by MatthewWilkes on 6/26/23, 3:49 PM

    Surprising that the only mention of intellectual property in the FAQ and the legal terms page is about copyright that the service claims in the outputs, not restrictions on the inputs.
  • by sergiotapia on 6/26/23, 5:21 PM

    Thank you, now I can remove Dababy from Dua Lipa - Levitating. https://www.youtube.com/watch?v=TUVcZfQe-Kw&pp=ygUTZHVhIGxpc...

    He just butchers an otherwise perfect song!

    Will report back with results.

    Edit: Results are great! https://voca.ro/13ar1g88LSKK

  • by lcnPylGDnU4H9OF on 6/26/23, 10:27 PM

    Seeing the domain has me curious, is it a reference to a Pokemon[0] or is it something else? (Sorry for off-topic!)

    > On repeat: Make an extended version of your song's favorite part by choosing the catchy part and seamlessly repeating part of it!

    John Mulaney's "Best Meal I Ever Had" story[1] had me wanting to do this for Tom Jones' What's New Pussycat so I could play that as an inside joke with some friends. This would definitely have made that easier. (Ultimately, I had a version of the song which started in the middle and "ended" right before it "started" so the effect could be mimicked if the file was played on loop. This had a short silence manifest as the media player "loaded a new song" from its perspective; didn't have that issue in Audacity.)

    [0] https://www.pokemon.com/us/pokedex/loudred

    [1] https://www.youtube.com/watch?v=Tv1l1eUhN-E (Usually called "The Salt and Pepper Diner")

  • by sd9 on 6/26/23, 4:16 PM

  • by codetrotter on 6/26/23, 3:55 PM

    > This is helpful for making any song match a video or performance with a set duration.

    This is perfect for TikTok videos!

    Will definitely be using your tool. Very cool!

    > I am thinking of writing up some more details about the implementation in the future.

    Please do :D

  • by personjerry on 6/26/23, 6:10 PM

    I'm enjoying the results, I can make my favourite tunes 10 minutes long and often it's pretty seamless! I can't wait to get sick of all my songs :)

    Is the project open-source?

  • by stu2010 on 6/26/23, 4:51 PM

    What's the maximum length? I can't find it documented anywhere and keep running into it when trying to try this with Tool tracks.
  • by jedberg on 6/26/23, 6:18 PM

    The way this works is interesting. I asked it to cut 30 seconds from the middle of a song (a spoken word portion without music) and then shorten the track by 30 seconds. I figured it would just cut that out and do some fancy blending of the music before and after the cut to make it sound good. Instead I got:

        at 00:00 a 00:16 segment (00:00–00:16)
        at 00:16 a 00:51 segment (02:05–02:57)
        at 01:07 a 02:31 segment (01:34–04:05)
        at 03:39 a 00:11 segment (04:03–04:14)
    
    It's adding and repeating chunks of the song and cutting other parts and I'm not sure why.
  • by quickthrower2 on 6/26/23, 4:34 PM

    I can finally see and hear what Bohemian Rapsody would have sounded like had they caved in to make a radio-friendly cut.
  • by redox99 on 6/26/23, 4:01 PM

    Does this create "new" music for the filled parts, like some AIs (MusicLM, MusicGen, etc) do? Or just repeat in a more seamless way?
  • by ConnorMooneyhan on 6/26/23, 4:50 PM

    I'm a tad disappointed. Cool idea, but I haven't gotten anything to really sound seamless when shortening or lengthening yet.
  • by superasn on 6/27/23, 7:06 AM

    This will be great for my programming music.

    Though it's just anecdotal but I have seen that the quickest way to enter into the zone is to play repeating loops at 140 bpm.

    Unfortunately I haven't really found many of these as most of the tracks I love are non looping. I think this can take care of it. Kudos on making this!

  • by kunalgupta on 6/26/23, 4:37 PM

    Perfect! You automated my hobby of extending music videos to last up to the max video length available on YouTube in 2008

    https://youtu.be/XCJs_eAkNS8

  • by LorenDB on 6/27/23, 3:42 PM

    This is pretty good! However, there are some unusual splices. One I found was with a recording of Cumberland Gap[0]. If you run a 10 minute loop, you'll find that the first splice in multiple tracks (happens at about the 2:30 mark), the song suddenly cuts to the middle of a mandolin solo that clearly doesn't belong there. With that being said, I'm still overall impressed by this.

    [0]: https://youtu.be/VAk4_CMn7To

  • by nicexe on 6/27/23, 7:15 AM

    I tried lengthening Another Day by Dream Theater from 4:26 to 8:00.

    I set it to avoid the segment that the key changes and to favor the 2 solo segments.

    It doesn't seem like its doing a good job. Only the first 5 seconds of the intro made it and then is just repeating over and over the big solo. In the end, a very small part of the short solo makes it in as an outro.

    Maybe it works better at shortening songs or maybe changing duration closer to the original duration.

  • by pradn on 6/26/23, 5:32 PM

    This is exciting. It adds to the tools creators have to remix songs. A middle ground between full AI and full human-made songs is a mix, like what Bronze AI has done with one of my favorite songs. (https://bronze.ai/listen/jai-paul/)

    A less rosy scenario is like Spotify generating music to get around having to pay artists.

  • by edonhametsu on 6/27/23, 5:37 AM

    If you're stuck on Loading (0 of 19), make sure you have a new enough Firefox version to support dynamic import for workers (https://bugzilla.mozilla.org/show_bug.cgi?id=1540913, i.e. 113 or newer).

    For example, ESR 102 does not have the feature and it breaks the site.

  • by personjerry on 6/26/23, 5:10 PM

    I created a 10 minute version of The Less I know The Better (https://mofi.loud.red/edit/dde278b8c131c1a6e47117ceb29d1ceb6...) but the export doesn't seem to work, it just errors out with "Invalid Crossfade" multiple times
  • by empyrrhicist on 6/27/23, 2:05 AM

    Are you worried about trademark infringement?

    https://mofi.com/

  • by cyberax on 6/26/23, 5:50 PM

    Can we use something like this to remove the laugh track, please? PLEASE?

    It needs to be generalized to video content, but the task is a bit easier.

  • by danhau on 6/26/23, 9:31 PM

    Very cool! It seems to struggle with mixed meter music, though (understandably). I've uploaded a song of mine that's mostly in 6/8, but has some bars of 7/8. It still makes smooth transitions, but on the wrong beat, which is very noticeable. I will try it again with a song in only one odd measure, maybe that works.
  • by benkaiser on 6/27/23, 1:51 AM

    Interesting how the youtube videos are pulled down in a cloud function and stored on a file host for caching. I know there is a disclaimer about making sure you have the applicable rights, and IANAL, but this is for sure violating some terms and potentially copyright when users are using videos they don't have rights to.
  • by emmanueloga_ on 6/26/23, 7:31 PM

    Really nice! Do you use a library or service to find the self similar points, or is it your work?

    Found a bunch of cool related links here [1].

    1: https://en.wikipedia.org/wiki/Music_information_retrieval

  • by personjerry on 6/26/23, 9:22 PM

    It would be cool if you could link to a particular cut (i.e. a five star 10 minute version I really like)
  • by Workaccount2 on 6/26/23, 5:35 PM

    Perhaps tangential to this project, but I have always wanted something that can detect different instruments/sounds and allow me to adjust the volume on them/remix them.

    There are a few songs I love, but some of the best parts seem to be "buried" under other instruments.

  • by EwanG on 6/26/23, 7:31 PM

    First thought was that we finally have an answer for Symphony No. 8 (https://en.wikipedia.org/wiki/Symphony_No._8_(Schubert))
  • by JonathanFly on 6/27/23, 5:14 AM

    What's the difference between "Search" and "Edit song"? It seems like Search is just about length, and Edit also considers sections you marked? Or does Edit do the same thing but with many edits, rather than a few?
  • by jonathantf2 on 6/26/23, 8:22 PM

    Seems kinda cool but I'm stuck on "Loading results... (0%, 0 of 19 done)"
  • by boffinAudio on 6/27/23, 6:57 AM

    I like this but there are a lot of studios in the world where I will never be able to access it, so I'd really like to have a standalone/non-web version if its at all possible. I'd pay for that.
  • by wpietri on 6/26/23, 6:04 PM

    My big question: what have you learned while working on this (very cool) project?
  • by SillyUsername on 6/27/23, 7:43 PM

    Please add the option for a longer fade out, plenty of songs finish too early and it would be great if they could just fade out rather than stop abruptly.
  • by smokeydoe on 6/26/23, 4:42 PM

    This works great with the clips made from MusicGen. The loops are seamless. Thank you for making it free. I would love to know more about how you are analyzing the audio.
  • by KolmogorovComp on 6/26/23, 4:14 PM

    Seems really nice, though for some reason after pasting a YouTube link it's stuck when reaching 100%, would have liked to give it a try.
  • by EGreg on 6/27/23, 6:48 AM

    Pretty soon I can see how people will make a content-aware fill for relationships, heartfelt messages etc
  • by netvarun on 6/26/23, 11:57 PM

    [offtopic] Could you share what tool you used to generate the demo gif/video? Very nicely done!
  • by JohnFen on 6/26/23, 5:42 PM

    Interesting. Is there any chance you would release this to run natively rather than as a web service?
  • by yumikai on 6/27/23, 5:04 PM

    Super cool, not what you would typically think of when it comes to gen music!
  • by omegaworks on 6/26/23, 6:11 PM

    Getting an SSL error - invalid HTTPS certificate. Site is being tagged as malware.
  • by hkab on 6/27/23, 1:47 AM

    Cool! It seems to work well with slow songs, the transition is very smooth
  • by yanuzay on 6/27/23, 8:50 AM

    It's possible to add multiple files and added them at once?
  • by peterdigital on 6/27/23, 1:14 AM

    Would love to sort by most cuts just to see what happens
  • by Pr0ject217 on 6/26/23, 11:18 PM

    This is pretty cool! Will you consider open-sourcing it?
  • by sundaeofshock on 6/26/23, 4:11 PM

    I know I’m in the minority here, but I hate it. The artist created created a song of a particular length for a very specific reason. I prefer to listen to a song the way it was meant to be listened too.
  • by 71a54xd on 6/26/23, 4:19 PM

    Do these get tagged by contentID on Youtube?
  • by xadoc on 6/27/23, 5:59 AM

    How do you get the audio from Youtube?
  • by IndigoIncognito on 6/27/23, 9:01 PM

    I wish google ranked services like these right at the top when users search for these tools, currently they are filled with ad filled, paywalled, slow & tedious media editing services

    I wouldn't mind giving money to services like this

  • by frankfrank13 on 6/26/23, 8:58 PM

    super fun to use. very useful right away
  • by okinawamist on 6/27/23, 5:13 PM

    very cool. is this purely DSP based?
  • by objectspace on 6/27/23, 7:33 PM

    Cool!
  • by ljlolel on 6/26/23, 3:47 PM

    Cool!