Page 1 of 2

How to export a pitched source/audio file

Posted: Tue Aug 02, 2022 12:35 am
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!

Re: How to export a pitched source/audio file

Posted: Tue Aug 02, 2022 2:12 am
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.

Re: How to export a pitched source/audio file

Posted: Tue Aug 02, 2022 5:18 am
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?

Re: How to export a pitched source/audio file

Posted: Tue Aug 02, 2022 1:48 pm
by PixliiTheGreat
Trying to make a chromatic scale generator for music to be used in FL Studio or smth like that.

Re: How to export a pitched source/audio file

Posted: Tue Aug 02, 2022 4:32 pm
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

Re: How to export a pitched source/audio file

Posted: Wed Aug 03, 2022 12:41 am
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!

Re: How to export a pitched source/audio file

Posted: Wed Aug 03, 2022 1:20 am
by pgimeno
What are the advantages of luawav over the built-in SoundData that zorg mentioned?

Re: How to export a pitched source/audio file

Posted: Wed Aug 03, 2022 4:23 am
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...

Re: How to export a pitched source/audio file

Posted: Thu Aug 04, 2022 7:51 pm
by pgimeno
Oh, you're right, I didn't notice that there's no audio encoder in SoundData.

Re: How to export a pitched source/audio file

Posted: Fri Aug 05, 2022 3:31 am
by ReFreezed
IMO, there really should be, since you can generate sound and even record sound from a mic, and you can encode images.