Author Topic: FMod help  (Read 8274 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
FMod help
« on: December 07, 2010 »
Guys,
I want to use FMod (or something similar if possible) to play either a .mp3 or .wav file.
I know how to get Fmod to play an .mp3/.wav file no problem at all, but once it is playing I need to be able to generate a spectrum analyser/equaliser on screen in realtime - does anybody know how to do this?
I will be using tinyptc to draw the equaliser too.

Thanks in advance . . .

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Moroboshisan

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 454
  • Karma: 18
  • C=64
    • View Profile
Re: FMod help
« Reply #1 on: December 08, 2010 »
I know for sure that there are more than one resource to look at:

http://www.dbfinteractive.com/forum/index.php/topic,519.0.html

it's for uFmod so some restrictions apply... but the basic steps shold be there... I'm diggin' the forum out to find some more infos...

cheers ;)

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #2 on: December 08, 2010 »
Thanks matey - I will take a look at that . . . ;)

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: FMod help
« Reply #3 on: December 08, 2010 »
Challenge Trophies Won:

Offline Moroboshisan

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 454
  • Karma: 18
  • C=64
    • View Profile
Re: FMod help
« Reply #4 on: December 08, 2010 »

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #5 on: December 08, 2010 »
Thanks a lot guys! :)
Does anybody have an instance of this working in FreeBasic - can't seem to get it to work?

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2756
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: FMod help
« Reply #6 on: December 08, 2010 »
How about bass?

You can download one example here:
http://www.rbraz.com/files/DBF-GVY_Camouflage_src.rar
Have everything you need to make a spectrum analyser/equaliser in fb.
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #7 on: December 08, 2010 »
Thanks rbz. I will take a look at that too.
Cheers

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #8 on: December 08, 2010 »
One small question - does the bass.dll play all formats or just .xm and .mod etc? :(
I need it to play .mp3 or .wav files really?

Cheers
Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2756
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: FMod help
« Reply #9 on: December 08, 2010 »
Quote
BASS is an audio library for use in Windows and Mac OSX software. Its purpose is to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a tiny DLL, under 100KB* in size.
Yes, it can play alot of formats.

For mp3 file which is called stream you can use:
Code: [Select]
stream = BASS_StreamCreateFile( false, "music.mp3", 0, 0, BASS_MUSIC_AUTOFREE |
   BASS_STREAM_PRESCAN |
   BASS_SAMPLE_FLOAT);

BASS_ChannelPlay(stream, true);
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #10 on: December 09, 2010 »
I still must be doing something wrong - anybody help with this . . . ?

Obviously you need to put an .mp3 of your own in there . . . :)

Code: [Select]
#include once "fmod.bi"
#Include once "tinyptc_ext.bi"
   
Dim Shared As Integer Xres,Yres,Value   
Xres=640:Yres=480:Value=0
Dim Shared As Integer MySong
Dim Shared As Uinteger Buffer(XRES*YRES)

#define pp(x,y,argb) buffer(y*XRES+x)=argb

FSOUND_Init(48000, 4, 0)
MySong = FSOUND_Sample_Load(FSOUND_FREE, "StangeByDPC.mp3", 0, 0, 0)
FSOUND_Sample_SetMode(MySong, FSOUND_LOOP_NORMAL)
FSOUND_DSP_GetFFTUnit()

PTC_ALLOWCLOSE(0)
PTC_SETDIALOG(0,"MP3 Player Test",1,0)               
IF (PTC_OPEN("Coded by AndyRCM aka DrewPee",XRES,YRES)=0) THEN
END-1
END IF

FSOUND_PlaySound(FSOUND_FREE, MySong)

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
PTC_UPDATE@Buffer(0)
FSOUND_Update
value=FSOUND_DSP_GetSpectrum()
print value;" ";
WEND
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2756
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: FMod help
« Reply #11 on: December 10, 2010 »
Seems you get stuck with it, so here an example for you to play:
Code: [Select]
#include once "fmod.bi"
#Include once "tinyptc_ext.bi"
   
Dim Shared As Integer Xres,Yres
Xres=640:Yres=480
Dim Shared MySong as FSOUND_SAMPLE ptr 'rbz
dim shared spectrum_buffer_ptr as single ptr 'rbz
spectrum_buffer_ptr =  allocate(512 * SizeOf(single)) 'rbz
Dim Shared As Uinteger Buffer(XRES*YRES)
dim as integer i,j'rbz
dim as single value'rbz

#define pp(x,y,argb) buffer(y*XRES+x)=argb

FSOUND_Init(48000, 4, 0)
MySong = FSOUND_Sample_Load(FSOUND_FREE, "srg7agosto.mp3", FSOUND_NORMAL, 0, 0)
FSOUND_Sample_SetMode(MySong, FSOUND_LOOP_NORMAL)
FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)'rbz

PTC_ALLOWCLOSE(0)
PTC_SETDIALOG(0,"MP3 Player Test",1,0)               
IF (PTC_OPEN("Coded by AndyRCM aka DrewPee",XRES,YRES)=0) THEN
END-1
END IF

FSOUND_PlaySound(FSOUND_FREE, MySong)

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
   
    spectrum_buffer_ptr=FSOUND_DSP_GetSpectrum()'rbz

    for i = 0 to 24 '(max 512)
        value = spectrum_buffer_ptr[i]
        locate i,1: Print Using "###.##"; (value*100)     
    next
   
    for i = 0 to 24
        value = spectrum_buffer_ptr[i] * 40.0
        for j = 0 to cast(integer, value)
            locate i,j+10: print "#                           "
        next
    next
   
    PTC_UPDATE@Buffer(0)

WEND

deallocate(spectrum_buffer_ptr)
FSOUND_Sample_Free(MySong)
FSOUND_Close
Just remember that FSOUND_DSP_GetSpectrum will return a pointer to a buffer containing 512 floats, in this example I just display 24, and make sure to use a proper scale for your needs  (value*scale_factor) .

My ASCII spectrum looks crap but I'm sure you will do better on ptc buffer :)
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #12 on: December 14, 2010 »
Thank you. Sorry I haven't replied sooner - just been to Oldenburg/Germany to visit a Retro Computer Museum! ;)

Cheers

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: FMod help
« Reply #13 on: December 14, 2010 »
That is exactly what I needed! Thank you so much! I will credit you with the code for this part of the project. ;) Massive thanks mate and Karma+ ;)

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk