Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Where to start?

  1. #11
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Where to start?

    Charles thanks, very cool sounds!

    In searching so far, I don't understand where the sounds are being generated. Is there deep down a windows api call that is made that takes the code and sends it to the sound hardware? I run across directsound which is part of directx and BASS even uses it, so I assume that is how it is done. Is this right direction for me to study up on?

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  2. #12
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Where to start?

    Hi Charles,

    those are some very cool sounds!
    w12.wav reminds me of some sound FX from original "Prince of Persia"


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #13

    Re: Where to start?

    Kent,

    DirectSound has a COM interface. My software went in at a lowerlevel feeding the sound buffer directly, controlling all aspects of the audio data. I think all the active buffers are mixed, volume controlled then fed to the sound hardware drivers.

    All the functions I used are part of MCI and can be found in PB's win32API.inc and are called waveout??something.

    Used these notes by Jeff Glatt below:
    Attached Files Attached Files

  4. #14
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Where to start?

    http://www.bervini.net/raffaello/

    Into the above link you will find a lot of very interesting Power Basic sources.
    Some of the works with sounds. On in particular generates very nice sound using MIDI interface. Search for "Suona file midi (PBWIN)".
    Some other works with FMOD lib, that is very interesting too and free if used inside free software (like thinBasic project)

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #15
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Where to start?

    Thanks for the links guys.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  6. #16
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Where to start?

    Very nice website,

    some really nice stuff like that software 3D engine, hmm

    Regarding MIDI, I used it in RobotDuel already, here is some minimal example with lot of scary sounds:
    [code=thinbasic]
    uses "Console"

    ' This API is needed for the sound
    DECLARE FUNCTION midiOutClose LIB "WINMM.DLL" ALIAS "midiOutClose" (BYVAL hMidiOut AS DWORD) AS LONG
    DECLARE FUNCTION midiOutOpen LIB "WINMM.DLL" ALIAS "midiOutOpen" (lphMidiOut AS DWORD, BYVAL uDeviceID AS DWORD, BYVAL dwCallback AS DWORD, BYVAL dwInstance AS DWORD, BYVAL dwFlags AS DWORD) AS LONG
    DECLARE FUNCTION midiOutShortMsg LIB "WINMM.DLL" ALIAS "midiOutShortMsg" (BYVAL hMidiOut AS DWORD, BYVAL dwMsg AS DWORD) AS LONG

    dim hMidiOut as dword
    dim midierror as long = midiOutOpen(hMidiOut, 0, 0, 0, 0)
    if midierror then msgbox 0, "Cannot init MIDI, program will not have sound"


    dim i, n as long

    for i = 1 to 255
    console_PrintLine("Instrument"+STR$(i))
    midi_SelectInstrument(i,0)

    midi_PlayNote(40, 100,0)
    sleep 1000
    next
    console_PrintLine("End of sounds ")
    midiOutClose(hMidiOut)
    console_WaitKey


    FUNCTION midi_PlayNote(note AS LONG, volume AS LONG, channel AS LONG) AS LONG
    LOCAL midimsg AS LONG, result AS LONG
    midimsg = &H90 + note*&h100 + volume*&h10000 + channel
    IF midiOutShortMsg(hMidiOut, midimsg) <> 0 THEN MSGBOX 0, "Error occured while trying to play note"+STR$(note)+" at volume"+STR$(volume)+" on channel"+STR$(channel)
    END FUNCTION

    FUNCTION midi_SelectInstrument( instrument AS LONG, channel AS LONG) AS LONG
    LOCAL midimsg AS LONG
    instrument -= 1
    midimsg = &HC0 + instrument*&h100 + 0*&h10000 + channel
    IF midiOutShortMsg(hMidiOut, midimsg) <> 0 THEN MSGBOX 0, "Error occured while setting up instrument"
    END FUNCTION
    [/code]


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #17

    Re: Where to start?

    Thank you Eros.

    Bervini Raffaello's music is good too.

    Here are some notes on the mci low level midi interface -
    Attached Files Attached Files

  8. #18
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Where to start?

    Thanks Petr for reminding of music without media via midi, good idea too.

    At least we can use that as a place holder till hardcore version is ready. I will tinker with it for tanks.

    Thanks for the link to Charles, the other one was neat. Will check this one out now.
    The site Eros linked to is very cool too!!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  9. #19
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    tank sound candidate #1

    Using Petr's example code and a little bit of tinkering came up with a first possible tank sound candidate.
    [code=thinbasic]uses "Console"

    ' This API is needed for the sound
    DECLARE FUNCTION midiOutClose LIB "WINMM.DLL" ALIAS "midiOutClose" (BYVAL hMidiOut AS DWORD) AS LONG
    DECLARE FUNCTION midiOutOpen LIB "WINMM.DLL" ALIAS "midiOutOpen" (lphMidiOut AS DWORD, BYVAL uDeviceID AS DWORD, BYVAL dwCallback AS DWORD, BYVAL dwInstance AS DWORD, BYVAL dwFlags AS DWORD) AS LONG
    DECLARE FUNCTION midiOutShortMsg LIB "WINMM.DLL" ALIAS "midiOutShortMsg" (BYVAL hMidiOut AS DWORD, BYVAL dwMsg AS DWORD) AS LONG

    dim hMidiOut as dword
    dim midierror as long = midiOutOpen(hMidiOut, 0, 0, 0, 0)
    if midierror then msgbox 0, "Cannot init MIDI, program will not have sound"


    dim i,c, n,x,y as long
    i = 40 'idle?
    for y = 1 to 10
    for x = 12 to 20
    console_PrintLine("Instrument"+STR$(i)+" note"+Str$(x))
    midi_SelectInstrument(i,0)

    midi_PlayNote(x, rnd(75,125),0)
    sleep 25
    next
    next
    i=32 'moving
    for y = 1 to 20
    for x = 12 to 20
    console_PrintLine("Instrument"+STR$(i)+" note"+Str$(x))
    midi_SelectInstrument(i,0)

    midi_PlayNote(x, rnd(75,125),0)
    sleep 25
    next
    next
    midi_PlayNote(x, 0,0)
    console_PrintLine("End of sounds ")
    console_WaitKey
    midiOutClose(hMidiOut)



    FUNCTION midi_PlayNote(note AS LONG, volume AS LONG, channel AS LONG) AS LONG
    LOCAL midimsg AS LONG, result AS LONG
    midimsg = &H90 + note*&h100 + volume*&h10000 + channel
    IF midiOutShortMsg(hMidiOut, midimsg) <> 0 THEN MSGBOX 0, "Error occured while trying to play note"+STR$(note)+" at volume"+STR$(volume)+" on channel"+STR$(channel)
    END FUNCTION

    FUNCTION midi_SelectInstrument( instrument AS LONG, channel AS LONG) AS LONG
    LOCAL midimsg AS LONG
    instrument -= 1
    midimsg = &HC0 + instrument*&h100 + 0*&h10000 + channel
    IF midiOutShortMsg(hMidiOut, midimsg) <> 0 THEN MSGBOX 0, "Error occured while setting up instrument"
    END FUNCTION[/code]
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  10. #20

    Re: Where to start?

    Kent,Petr

    This will give you just about everything you need to know about programming MIDI

    MIDI Technical Fanatic's Brainwashing Center


    Lesser life forms communicate in more primitive, less artistic manners such as barks, chirps, roars, or any of the many human verbal languages in use throughout the globe. But, gods communicate using MIDI messages. Even a picture, whose value is often equated to a thousand words, cannot match the scope of emotional and intellectual power unleashed by a stream of MIDI messages. But, try to tell that to the visual-and-print-fixated, tone-deaf heathen who infest this planet...
    http://www.borg.com/~jglatt/

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. thinSVN (02): what do you need to start
    By ErosOlmi in forum thinSVN
    Replies: 0
    Last Post: 15-04-2009, 17:21

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •