Happy birthday dodicat
Happy birthday dodicat
Happy birthday dodicat 



Last edited by srvaldez on Oct 26, 2024 22:20, edited 1 time in total.
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
Oh happy birthday !!!
how old are you becoming ?
My best wishes... good health, happy years !
how old are you becoming ?
My best wishes... good health, happy years !
Re: Happy birthday dodicat
Best wishes for your Birthday dodicat stay fit and healthy 

-
- Posts: 494
- Joined: Sep 28, 2013 15:08
- Location: Germany
Re: Happy birthday dodicat
Happy birthday dodicat, good health and many thanks for all your inspiring contributions and helpful advices in this forum! 

-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
Hey let's create a freebasic bas file that beeps happy birthday song...
Is there a beep() function that creates 8-bit sound tone in some duration ?
Is there a beep() function that creates 8-bit sound tone in some duration ?
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
Happy Birthday from freebasic
Code: Select all
#Include "windows.bi"
' Define frequencies for each note (in Hz)
Const C4 = 261
Const D4 = 293
Const E4 = 329
Const F4 = 349
Const G4 = 392
Const A4 = 440
Const B4 = 493
Const C5 = 523 ' Higher octave C
' Melody and rhythm for "Happy Birthday"
Dim As Integer melody(24)
Dim As Integer rhythm(24)
' Initialize melody array
melody(0) = C4: melody(1) = C4: melody(2) = D4: melody(3) = C4: melody(4) = F4: melody(5) = E4
melody(6) = C4: melody(7) = C4: melody(8) = D4: melody(9) = C4: melody(10) = G4: melody(11) = F4
melody(12) = C4: melody(13) = C4: melody(14) = C5: melody(15) = A4: melody(16) = F4: melody(17) = E4
melody(18) = D4: melody(19) = A4: melody(20) = A4: melody(21) = F4: melody(22) = G4: melody(23) = F4
' Initialize rhythm array (in milliseconds)
rhythm(0) = 500: rhythm(1) = 250: rhythm(2) = 500: rhythm(3) = 500: rhythm(4) = 500: rhythm(5) = 1000
rhythm(6) = 500: rhythm(7) = 250: rhythm(8) = 500: rhythm(9) = 500: rhythm(10) = 500: rhythm(11) = 1000
rhythm(12) = 500: rhythm(13) = 250: rhythm(14) = 500: rhythm(15) = 500: rhythm(16) = 500: rhythm(17) = 500
rhythm(18) = 1000: rhythm(19) = 500: rhythm(20) = 250: rhythm(21) = 500: rhythm(22) = 500: rhythm(23) = 1000
' Play the melody using Windows API Beep_
For i As Integer = 0 To UBound(melody)
Beep_ melody(i), rhythm(i) ' Play note with frequency and duration
Next i
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
A quick fix for the tempo
Code: Select all
For i As Integer = 0 To UBound(melody)
Beep_ melody(i), rhythm(i) ' Play note with frequency and duration
Sleep(rhythm(i) - 200) ' Pause with adjusted timing
Next i
-
- Posts: 494
- Joined: Sep 28, 2013 15:08
- Location: Germany
Re: Happy birthday dodicat
I experienced problems using sequences of beep_ in Windows 11 without a short pause between each sound. Is this the reason for your changed code?
I created a subset of the good old PLAY command (QBASIC) for FreeBASIC using beep_ in order to reactivate some nice melodies programmed by my daughter in QuickBASIC 4.5 more than 30 years ago (https://www.freebasic-portal.de/downloa ... c-172.html). Worked well with Windows 8.1, but not with Windows 11. Without pauses, a lot of tones are corrupted or are supressed. Perhaps I will update the library. PLAY works well with QB64 (tested with QB64 Phoenix Edition).
I created a subset of the good old PLAY command (QBASIC) for FreeBASIC using beep_ in order to reactivate some nice melodies programmed by my daughter in QuickBASIC 4.5 more than 30 years ago (https://www.freebasic-portal.de/downloa ... c-172.html). Worked well with Windows 8.1, but not with Windows 11. Without pauses, a lot of tones are corrupted or are supressed. Perhaps I will update the library. PLAY works well with QB64 (tested with QB64 Phoenix Edition).
Re: Happy birthday dodicat
Thank you everybody.
demosthenesk, your tune sounds good here.
Lothar Schirm, your moonlight shadow plays OK here on Win 11.
The crt.bi has _beep, which plays demosthenesk's tune just fine, using the arrays in the same way.
demosthenesk, your tune sounds good here.
Lothar Schirm, your moonlight shadow plays OK here on Win 11.
The crt.bi has _beep, which plays demosthenesk's tune just fine, using the arrays in the same way.
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
The first time without sleep() in Win11 played well but after some time i had tune overlap so i insert sleep() to check that tune will be sound wellLothar Schirm wrote: ↑Oct 28, 2024 10:36 I experienced problems using sequences of beep_ in Windows 11 without a short pause between each sound. Is this the reason for your changed code?
I created a subset of the good old PLAY command (QBASIC) for FreeBASIC using beep_ in order to reactivate some nice melodies programmed by my daughter in QuickBASIC 4.5 more than 30 years ago (https://www.freebasic-portal.de/downloa ... c-172.html). Worked well with Windows 8.1, but not with Windows 11. Without pauses, a lot of tones are corrupted or are supressed. Perhaps I will update the library. PLAY works well with QB64 (tested with QB64 Phoenix Edition).
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
i like that you are happy with my freebasic gift for your birthday.... be well !

-
- Posts: 494
- Joined: Sep 28, 2013 15:08
- Location: Germany
Re: Happy birthday dodicat
Strange! With _beep from crt.bi I have the same problem. Maybe a hardware problem with my laptop? (My daughter who wrote these QB45 programs in the age of 16 or 17 has also birthday at October 26).
Last edited by Lothar Schirm on Oct 28, 2024 18:51, edited 1 time in total.
-
- Posts: 293
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: Happy birthday dodicat
Well wishes to her also Lothar !Lothar Schirm wrote: ↑Oct 28, 2024 16:21Strange! With _beep from crt.bi I have the same problem. Maybe a hardware problem with my laptop? (My daughter who wrote these QB45 programs in the age of 14 or 15 has also birthday at October 26).
-
- Posts: 494
- Joined: Sep 28, 2013 15:08
- Location: Germany
Re: Happy birthday dodicat
Thank you!
I think I will not update my PLAY library since it seems to work well on some other computers, but I cannot really solve the problem for me. Also with a small pause between beeps it's not perfect. And the syntax of PLAY is ....
I find that your method of using an array of tones is a very clear and well readable code.
I think I will not update my PLAY library since it seems to work well on some other computers, but I cannot really solve the problem for me. Also with a small pause between beeps it's not perfect. And the syntax of PLAY is ....

Re: Happy birthday dodicat
Me was boring again...
Note: this code is too big to fail. Feel free to use it in any Boeing airplane firmware...
Code: Select all
#Include "windows.bi"
DIM AS STRING note="CCDDEFFGGAAB"
DIM AS STRING dursymbol="=_/+-;:,."
DIM AS INTEGER duration(8)={2000,1000,500,333,250,167,125,83,65}
DIM AS STRING melody
DIM AS INTEGER p, f, d
DIM AS UBYTE c
DIM AS INTEGER frequency(132)={ _
16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
131, 0, 0, 0, 0, 0, 0, 0, 208, 220, 233, 247, _
262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, _
523, 554, 587, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
1047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
2093, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
4186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
8372, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
16744, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
melody="C4/C4:D4/C4/F4/E4_C4/C4-D4/C4/G4/F4_C4/C4-C5/A4/F4/E4/D4_A#4/A#4-A4/F4/G4/F4_"
p=0
WHILE p<LEN(melody)
c=melody[p]
f=INSTR(note,CHR(c))
IF f THEN
p+=1
c=melody[p]
IF c=35 THEN ' #
IF f=12 THEN f-=1
p+=1
c=melody[p]
ELSE
f-=1 ' stringpos to index value
ENDIF
IF c>47 AND c<58 THEN
f+=(c-48)*12
ELSE
f=48
ENDIF
' ELSE pause
ENDIF
p+=1
c=melody[p]
d=INSTR(dursymbol,CHR(c))
IF d THEN d-=1
BEEP_ frequency(f), duration(d)
p+=1
WEND
SLEEP 2000
END