How to export a pitched source/audio file

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
PixliiTheGreat
Prole
Posts: 3
Joined: Tue Aug 02, 2022 12:14 am

How to export a pitched source/audio file

Post by PixliiTheGreat »

Hi, I'm fairly new to LÖVE developing and i'm trying to make a script that pitches a sample up and then exports it into a folder. I'm having trouble exporting the sound. I'm aware of the Source:setPitch script, but I'm not sure how to export the pitched file. If anyone could help, I would be immensely grateful. Thanks!
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: How to export a pitched source/audio file

Post by ReFreezed »

There's currently no function in LÖVE for saving audio files. You'll have to use a library or roll your own solution.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to export a pitched source/audio file

Post by zorg »

To be more on point, you can't get back audio (that you applied effects to) from a Source object.
You would need to implement your own pitch changing algorithm, modify all samplepoints in a SoundData object instead, and then write all of that out to disk, encoded in the format of your choice (again, you'd need to implement the encoder as well; wav is the simplest to do.)

Why do you want to export these though?
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
PixliiTheGreat
Prole
Posts: 3
Joined: Tue Aug 02, 2022 12:14 am

Re: How to export a pitched source/audio file

Post by PixliiTheGreat »

Trying to make a chromatic scale generator for music to be used in FL Studio or smth like that.
User avatar
darkfrei
Party member
Posts: 1172
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to export a pitched source/audio file

Post by darkfrei »

ReFreezed wrote: Tue Aug 02, 2022 2:12 am There's currently no function in LÖVE for saving audio files. You'll have to use a library or roll your own solution.
Loke this? https://github.com/jprjr/luawav
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
PixliiTheGreat
Prole
Posts: 3
Joined: Tue Aug 02, 2022 12:14 am

Re: How to export a pitched source/audio file

Post by PixliiTheGreat »

darkfrei wrote: Tue Aug 02, 2022 4:32 pm
ReFreezed wrote: Tue Aug 02, 2022 2:12 am There's currently no function in LÖVE for saving audio files. You'll have to use a library or roll your own solution.
Loke this? https://github.com/jprjr/luawav
Looks good. Thanks a lot!
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to export a pitched source/audio file

Post by pgimeno »

What are the advantages of luawav over the built-in SoundData that zorg mentioned?
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: How to export a pitched source/audio file

Post by ReFreezed »

pgimeno wrote: Wed Aug 03, 2022 1:20 am What are the advantages of luawav over the built-in SoundData that zorg mentioned?
Encoding the wav file...
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to export a pitched source/audio file

Post by pgimeno »

Oh, you're right, I didn't notice that there's no audio encoder in SoundData.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: How to export a pitched source/audio file

Post by ReFreezed »

IMO, there really should be, since you can generate sound and even record sound from a mic, and you can encode images.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests