sfxr.lua - Generate sounds dynamically at runtime

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by murks »

Too bad about the broken "demo" program as it would be really useful for creating sounds and the code that creates it. I got it to work with löve 0.9, a pre löve 0.10 version of frames and a few simple edits, but it still crashes when I hit any of the "randomize" buttons.
It is useable, but it would be so much better to have a version that works properly without hassle.
hoistbypetard
Prole
Posts: 26
Joined: Fri May 22, 2020 7:00 pm

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by hoistbypetard »

Sorry if it's bad form to resurrect this thread. If so, let me know and I will start a new one.

I was excited to find this because I wanted similar functionality in a project I'm working on. So I spent some time over the past couple of nights getting it to work nicely with 11.3. After building the original (C/SDL) sfxr tool on Linux, I decided that it would be easier to fix this up than to generate builds of the original one for my collaborators to use. It was!
screenshot of the demo running on windows 10.
screenshot of the demo running on windows 10.
demo_screenshot.png (46.62 KiB) Viewed 10588 times
I used @linux-man's fork of LoveFrames with 11.x support and have posted a PR for @nucular's sfxr.lua repository here. I hope that will get merged in some form. If anyone wants to kick the tires in the meantime or would just find this as useful as I have, I've attached a .love archive to this post.
Attachments
sfxr_demo.love
An archive of the demo as submitted in my PR
(608.21 KiB) Downloaded 376 times
User avatar
zorg
Party member
Posts: 3477
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by zorg »

Nah, this i think is one of the legit cases where bumping old threads is fine, since it's on-topic AND you basically worked to do some compatibility edits on the old project to get it working again. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by gingerbeardman »

Just to say that I'm using this in 2025 with the PR mentioned above

Plus the getDirectoryItems fix mentioned on that PR.
Plus my own fix so space plays the current sound.

Fixed love file in post below.

(sorry don't know why it's picked up the .zip extension)

Thanks to all involved!
Screen shot 2025-03-10 at 12.50.05.png
Screen shot 2025-03-10 at 12.50.05.png (153.76 KiB) Viewed 1400 times
Last edited by gingerbeardman on Mon Mar 10, 2025 8:36 pm, edited 2 times in total.
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by gingerbeardman »

I got a bit carried away and have added a history feature with picker list and undo/redo, I'll look to make a PR soon and will upload another version here soon when I'm happy with it.

My use case is that I use random and mutate extensively to discover interesting sounds, but often miss a good one. Now we can go back to a previous sound.

edit:
- added "auto play on changes" so that any time you adjust a slider the sound plays
- fixed a bug where the selected wave form was being ignored (sounds were always square wave)
- fixed wave form not updating when sound was loaded (but sound was playing correctly)
- fix off by one error as shown in a sfxrlua PR
- added keyboard navigation in file picker (type a-z to jump between files, enter to choose selected, esc to close picker)

macOS and Windows binaries now available for free on itch: https://gingerbeardman.itch.io/enhanced-sfxr-for-love2d
Screen shot 2025-03-11 at 18.09.19.png
Screen shot 2025-03-11 at 18.09.19.png (179.93 KiB) Viewed 1286 times
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by gingerbeardman »

macOS and Windows binaries now available for free on itch: https://gingerbeardman.itch.io/enhanced-sfxr-for-love2d
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by gingerbeardman »

updated build at itch that includes better filename and save directory handling
User avatar
darkfrei
Party member
Posts: 1250
Joined: Sat Feb 08, 2020 11:09 pm

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by darkfrei »

gingerbeardman wrote: Wed Mar 12, 2025 6:53 pm macOS and Windows binaries now available for free on itch: https://gingerbeardman.itch.io/enhanced-sfxr-for-love2d
I've got the error:

Code: Select all

Error

sfxr.lua:1257: bad argument #1 to 'char' (invalid value)


Traceback

[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'char'
sfxr.lua:1257: in function 'bytes'
sfxr.lua:1264: in function 'w16'
sfxr.lua:1310: in function 'exportWAV'
main.lua:679: in function 'cb'
main.lua:586: in function 'onclick'
loveframes/loveframes/objects/button.lua:162: in function 'mousereleased'
loveframes/loveframes/objects/frame.lua:628: in function 'mousereleased'
loveframes/loveframes/objects/base.lua:143: in function 'mousereleased'
loveframes/loveframes/init.lua:244: in function <loveframes/loveframes/init.lua:241>
[love "callbacks.lua"]:154: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by gingerbeardman »

Thanks! I'll look into it this week.

@darkfrei if you have a lua or sfs file that can reproduce this it could save me some time?
User avatar
darkfrei
Party member
Posts: 1250
Joined: Sat Feb 08, 2020 11:09 pm

Re: sfxr.lua - Generate sounds dynamically at runtime

Post by darkfrei »

gingerbeardman wrote: Sun Mar 23, 2025 9:36 pm Thanks! I'll look into it this week.

@darkfrei if you have a lua or sfs file that can reproduce this it could save me some time?
It was sfxr_demo.love
156 kB from your link.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 4 guests