FMod for .WAV, .MP2, .MP3, .OGG, .RAW

Previous topic - Next topic

Schranz0r

Update: 20.08.08
NOW: Version 1.0 !


Features:
  • load .WAV, .MP2, .MP3, .OGG, .RAW -files and play it.
  • get current time in minutes/seconds by BYREF ( FM_GetTime(Samplehandle, BYREF minutes, BYREF seconds)
  • get spectrum data ( FM_DSPGetSpectrum(spec[], num_Specs = 256)  // for mixrate 44100: DIM Spec[256] , num_specs = 256 !)
  • get songname
  • set volume
  • get IsPlaying ( FM_IsPlaying(Samplehandle) )

    Next Features:
  • set loops
  • pause-function
  • set FX <---- thats a hard part !!!
  • Linux/Mac Support

    Screenshot:



    like this:


    Code (glbasic) Select
    SYSTEMPOINTER TRUE

    LOCAL Init = FM_Init()


    LOCAL Sample = FM_LoadSample("DHS - IK+ (Chemical Stadium Remix).mp3",FSOUND_NORMAL)
    LOCAL Play = FM_PlaySound(Sample)
    LOCAL FFT = FM_DSPGetFFTUnit()
    FM_DSPSetActive(FFT)

    LOCAL Spec[]
    DIM Spec[256]

    LOCAL Vol = 255





    WHILE TRUE

    LOCAL minutes, seconds,i

    INC Vol, MOUSEAXIS(2)*5
    IF Vol > 255 THEN Vol = 255
    IF Vol < 0 THEN Vol = 0

    FM_GetTime(Sample, minutes, seconds)

    PRINT "FMod-Wrapper v1.0, only for GLBasic.com!",10,10
    PRINT "by Schranz0r", 10,30
    PRINT "Songname: "+FM_GetName$(Sample),10,50
    PRINT "IsPlaying: "+FM_IsPlaying(Sample),10,70
    PRINT "Volume(use mouseweel): "+Vol,10,90
    PRINT "Samplelength: "+FM_GetLength(Sample),10,110
    PRINT "CurrentPos: "+FM_GetCurrentPosition(Sample),10,130
    PRINT "Song in Sec: "+FM_GetLengthInSeconds(Sample),10,150
    PRINT "Current Position in Sec: "+FM_GetCurrentPositionInSeconds(Sample),10,170

    IF seconds < 10
    PRINT "Time: "+ minutes+":0"+seconds, 10,190
    ELSE
    PRINT "Time: "+ minutes+":"+seconds, 10,190
    ENDIF

    FM_DSPGetSpectrum(Spec[])

    FOR i = 0 TO LEN(Spec[])-1
    IF Spec[i] > 0.5 THEN Spec[i] = 0.5
    IF Spec[i] < 0 THEN Spec[i] = 0
    DRAWLINE 100+i, 400, 100+i, 400-Spec[i]*500, RGB(i, 255-i, 0)
    NEXT

    FM_SetVolume(Sample,Vol)

    IF FM_IsPlaying(Sample) AND MOUSEAXIS(3) THEN FM_StopSound(Sample)
    IF FM_IsPlaying(Sample) = 0 AND MOUSEAXIS(4) THEN FM_PlaySound(Sample)


    SHOWSCREEN
    WEND
    FM_Close()
    END


    You can see, thats very simple (thats the goal). My wrapper contains a channel, filename and soundfile handling!

    Download it NOW (link broken! -> old Post :) )

    [attachment deleted by admin]
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Quentin

Wow! Klasse Sache. ... I mean class thing  =D

BumbleBee

The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

Schranz0r

ist jetzt schon ein wenig weiter :)
evtl kommt morgen ein Update ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Sebastian

Schranz0r, was planst dunoch für den Wrapper? Funktionen mit denen man diverse Aspekte der geladenen Musik auslesen und verwerten kann (Stichwort: Musikspiele) wären toll! Umso mehr, da z.B. auch Guitar Hero ja Fmod benutzt und demenstprechende Funktionen enthalten sein müssten. Ich hab mich schon an irrKlang versucht aber so viel OOP  :S

Schranz0r

Man kann wohl den Höhenausschlag abfragen stichwort Audiosurf :D
Muss mal gucken wie das genau geht:)

Bin schon ein wenig weiter, werde evtl morgen nochmal ein Update raufladen ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Sebastian

Genau darauf wollte ich hinaus. Hab nämlich eine Idee für ein Musikspiel und da käme mir ein Fmod Wrapper natürlich grade recht  :whistle:

Moru

Looking good!
Will I be able to load an mp3 file and start playing at any location inside the mp3?

Schranz0r

yes ;)

You can set a start-endpoint for a loop
ect..
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

Great, I want an audiobook player than can remember where you were on quit. Is it running on GP2X? ;-)

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

ah, ok. Still interesting for listening to audiobooks on the PC but sadly not possible for GP2X then. Looking forward for the finnished version :-)

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Sebastian

Schranz0r, wenn das auch noch auf dem Pandora läuft... gut, ein Held bist du eh schon, aber:  :nw:

acristo