QB SOUND

New to FreeBASIC? Post your questions here.
dodicat
Posts: 8297
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: QB SOUND

Post by dodicat »

yevrowl wrote: Jul 02, 2025 10:58 Implemented it this way:

Code: Select all

Declare Function WindowsBeep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Sub notes
    If n = 1 Then WindowsBeep (100, 1000)
    If n = 2 Then WindowsBeep (200, 1000)
    If n = 3 Then WindowsBeep (300, 1000)
    If n = 4 Then WindowsBeep (400, 1000)
    If n = 5 Then WindowsBeep (500, 1000)
    If n = 6 Then WindowsBeep (600, 1000)
    If n = 7 Then WindowsBeep (700, 1000)
    If n = 8 Then WindowsBeep (800, 1000)
    If n = 9 Then WindowsBeep (900, 1000)
    If n = 10 Then WindowsBeep (1000, 1000)
End Sub
Hope it will compile for FreeBSD too...
You don't need to load kernel32.dll, it is already loaded, see the compiler log in your editor
Variation:

Code: Select all

#cmdline "-v"
Declare Function WindowsBeep  Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Sub notes(n as long)
    If n = 1 Then WindowsBeep (100, 1000)
    If n = 2 Then WindowsBeep (200, 1000)
    If n = 3 Then WindowsBeep (300, 1000)
    If n = 4 Then WindowsBeep (400, 1000)
    If n = 5 Then WindowsBeep (500, 1000)
    If n = 6 Then WindowsBeep (600, 1000)
    If n = 7 Then WindowsBeep (700, 1000)
    If n = 8 Then WindowsBeep (800, 1000)
    If n = 9 Then WindowsBeep (900, 1000)
    If n = 10 Then WindowsBeep (1000, 1000)
End Sub

sub pn cdecl(count As integer, ...)
     var a= cptr(integer ptr,@count+1)
    For i as long = 0 To count-1
         print i+1;" of ";count
        notes(*(a+i))
    Next
End sub

#define playnotes(start...) pn(__FB_ARG_COUNT__(start),start)


playnotes(1,2,3,4,5,6,7,8,9,10)
print "Done . .. press any key"
sleep 
Post Reply