Create a musical note

Just starting out? Need help? Post your questions and find answers here.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 566
Joined: Tue Jan 04, 2011 6:21 pm

Create a musical note

Post 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 :idea:

PS: I would like to put the program and the sound in a single EXE.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
NicTheQuick
Addict
Addict
Posts: 1517
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Create a musical note

Post 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
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
AZJIO
Addict
Addict
Posts: 2183
Joined: Sun May 14, 2017 1:48 am

Re: Create a musical note

Post by AZJIO »

User avatar
SPH
Enthusiast
Enthusiast
Posts: 566
Joined: Tue Jan 04, 2011 6:21 pm

Re: Create a musical note

Post by SPH »

I would like to create simple "BLIIING"
Thank you for your answers...

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
idle
Always Here
Always Here
Posts: 5888
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Create a musical note

Post 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
User avatar
SPH
Enthusiast
Enthusiast
Posts: 566
Joined: Tue Jan 04, 2011 6:21 pm

Re: Create a musical note

Post 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.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
idle
Always Here
Always Here
Posts: 5888
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Create a musical note

Post 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.
User avatar
NicTheQuick
Addict
Addict
Posts: 1517
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Create a musical note

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply