Page 1 of 1
Create a musical note
Posted: Sun Jun 01, 2025 2:24 pm
by SPH
Hi,
Can we create a musical note using mathematical calculations?
If not, can we convert them to Data?
Do you have an example?
Thanks
PS: I would like to put the program and the sound in a single EXE.
Re: Create a musical note
Posted: Sun Jun 01, 2025 3:16 pm
by NicTheQuick
Do you wanna render a note graphically or do you wanna make a sound using mathematical functions, like for example a simple sine wave?
For rendering notes you can use a free font like this one:
https://github.com/MuseScoreFonts/Leland
For creating a sine wave, just use `Sin()` a create an array of as many samples you need in the right frequency. Here's a simple example:
Code: Select all
EnableExplicit
Define seconds.f = 1
Define frequency.f = 1234
Define samplerate.i = 44100
Define samples = samplerate * seconds
Dim samples.f(samples - 1)
Define sample.i, time.f
For sample = 0 To samples - 1
time = sample / samplerate
samples(sample) = Sin(time * frequency)
Next
Re: Create a musical note
Posted: Sun Jun 01, 2025 3:54 pm
by AZJIO
Re: Create a musical note
Posted: Sun Jun 01, 2025 8:58 pm
by SPH
I would like to create simple "BLIIING"
Thank you for your answers...
Re: Create a musical note
Posted: Sun Jun 01, 2025 10:27 pm
by idle
Pb supports mod sounds natively. I'm sure a Google search will turn up a trove of free retro mod sounds.
There's also ym and sndc player if you want Amiga like sounds in addition to mod xm sounds but they require a dll. For the chip emulator.
Or you can use PBSpotFX by Demivec compile with x86 ASM backend
https://atomicwebserver.com/PBSpotFX.zip
Re: Create a musical note
Posted: Mon Jun 02, 2025 8:44 am
by SPH
I know MODs; I have Mod Anthology (the complete Amiga series).
I'm not looking for music, but sound effects like stones colliding and the like.
Above all, remember one thing: I want to put them as data in my exe so that my program fits in a single exe.
Or, if you know how to put WAV sound effects as data, I'd love some PB code.
Thanks.
Re: Create a musical note
Posted: Mon Jun 02, 2025 9:54 am
by idle
SPH wrote: Mon Jun 02, 2025 8:44 am
I know MODs; I have Mod Anthology (the complete Amiga series).
I'm not looking for music, but sound effects like stones colliding and the like.
Above all, remember one thing: I want to put them as data in my exe so that my program fits in a single exe.
Or, if you know how to put WAV sound effects as data, I'd love some PB code.
Thanks.
Cant PBSpotFx do that?
and if not there are tons of sound FX samples to be found for free online.
Re: Create a musical note
Posted: Mon Jun 02, 2025 10:11 am
by NicTheQuick
SPH wrote: Mon Jun 02, 2025 8:44 amOr, if you know how to put WAV sound effects as data, I'd love some PB code.
That's easy. Just look for `CatchSound()` in the help. There's also a mini example.