Author Topic: Freebasic MiniFmod 1.70  (Read 23595 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #20 on: March 08, 2009 »
Fantastic stuff Rbraz and Hellfire.

I have a few questions; when synching with samples / instruments( I believe they are the same ), are there any flags like you decribed with the checking for notes? I noticed that Shockwave is taking 45 away from the value,not sure why. And is there a place to get more information.

And with channels, are these the track numbers, or something completely different?

I ask, as I have made a CheckSong function for Synching, but I have noticed that it triggers an action more than it should do, it should carry out the task just the once. Do you recon I need a timer in place, or is there a flag from the synching command?

Code: [Select]

Dim Key As String
While Key<>Chr(27)

locate 1,1

If CheckSong( SampleNo1, Track1 ) Then Print"Here the drummer get wicked"&"                  "

Key=Inkey()

Wend

Function CheckSong( ByVal Sample As Integer, ByVal ChannelNo ) As Integer
   
    Dim As Integer a, result, SyncChannel
   
    Dim As Integer ChannelAmount=MiniFmod_GetChannels()
   
    Dim As Integer SampleCheck'( ChannelAmount )

    Result=False
    'For a=0 to ChannelAmount-1
       
        SampleCheck=MiniFmod_GetSynch( ChannelNo )
        SampleCheck=SampleCheck Shr 8'and &HFF
       
        Print "Sample/Instrument: "&str(Sample)&" "&Str(SampleCheck)&"                               "
               
        If int(SampleCheck(a))=Sample Then
           
            Result=True
            Return Result
            Exit Function
        End if
   
    'Next
   
    Return Result
   
End Function

Cheers and many thanks,
Clyde.

Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Freebasic MiniFmod 1.70
« Reply #21 on: March 08, 2009 »
Quote
when synching with samples / instruments( I believe they are the same )
Yes, let's consider it's the same thing.

Quote
And with channels, are these the track numbers, or something completely different?
Channels and tracks are the same thing here, sorry If I do confuse you with that terminology..

Quote
I ask, as I have made a CheckSong function for Synching, but I have noticed that it triggers an action more than it should do, it should carry out the task just the once.
If you look carefully at that example I've included you will notice that MiniFmod_GetSynch returns an unsigned integer which it's high word contains the sample (or instrument) number and the low word contain the note being played

Code: [Select]
     'Get channel to synch
      'return sample/instrument at uinteger hi word and note on low word
      'for desired channel passed to the function
      inst_note = MiniFmod_GetSynch(synchChannel)
      samp = inst_note shr 8 'hiword = sample/inst
      note = inst_note and &hff 'loword = notes

In resume, you can "filter" which sample/instrument number you need and retrieve it's note.
In the code above imagine if your drum (boom boom boom :)) sample is the number 01 and it's on track 2, you would do it like this:

inst_note = MiniFmod_GetSynch(2)
samp = inst_note shr 8            'hiword = sample/inst
note = inst_note and &hff        'loword = notes
if (samp=1) then
 if (note=the_note_that_I_want) then do_something...
endif

Hope that help a bit...


« Last Edit: March 08, 2009 by rbz »
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #22 on: March 08, 2009 »
Cheers for clarifying buddy :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Freebasic MiniFmod 1.70
« Reply #23 on: March 08, 2009 »
Just an FYI:

FB has built-in HiWord and LoWord macros:

http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgHiword
http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgLoWord

Nothing really different than doing it manually, but it does provide some self-documentation on the code.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #24 on: March 08, 2009 »
Cool beans.

One minor thing I am a bit stuck with, in ModPlugTracker aka MPT. It shows the notes as for example C-5 next door to the sample. The note + octave is used for the speed of the sample. So Im not too sure on what to feed for the note filtering?

I am beginning to realize and think that the syncing in your MiniFmod170 lib is performed quicker than in Bass, as I get completely different results with the same routines.

I'd love to be able to make stuff like this, perhaps one day.

Your favourite Fuzzy Wuzzy,
Clyde Radcliffe
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Freebasic MiniFmod 1.70
« Reply #25 on: March 09, 2009 »
Quote
Fantastic stuff Rbraz and Hellfire.
Well, I was just pointing out the obvious while Rbz had all the work, so all credit should go to him:
Well done Rbz! :)
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #26 on: June 15, 2009 »
Reply #24 must of got over looked.

im having problems with getting the volume to set to a desired range, using the following. ( btw, it's in a loop the part for altering / fading the volume )

Code: [Select]
dim volume as single=1.0

Volume-=0.20
if Volume<0.0 then Volume=0.0
           
MiniFmod_SetVolume( Volume )

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Freebasic MiniFmod 1.70
« Reply #27 on: June 16, 2009 »
@Clyde: this library takes some time to update the volume changed, I don't know if there's a way to speed it up, anyway check out this example below, it changes the volume waiting 100 millisecs in steps of 0.01.
If you want steps of 0.2 use a timer of 1000 or 1500 and check what happens.

About reply #24, I dunno. Maybe you can make a dummy sequence using that note C-5 and see what value minifmod will return for you, just use the code below to do this job for you.


Code: [Select]
' ===========================================================================
' MiniFMOD replayer
' Copyright (c), Firelight Multimedia, 2000.
'
' Freebasic compatible library version by rbz - 24 Dec 2008
' Synch method/idea by Hellfire
' ===========================================================================

#include "windows.bi"
#include "minifmod170.bi"

'Include song
#include "Virgil_Turrican.bas"

  Cls
  Locate 1, 1
 
  Print "-------------------------------------------------------------"
  Print "MiniFMOD example XM player"
  Print "Copyright (c) Firelight Multimedia, 2000"
  Print ""
  Print "Freebasic compatible library and wrapper by rbz - 24 Dec 2008"
  Print "Synch method/idea by Hellfire"
  Print "-------------------------------------------------------------"
  'Initialise MiniFmod
  'MiniFmod_Init(@MusicBuffer(0), size)
  '@MusicBuffer(0) => pointer to (.xm) fastracker song buffer
  'size => song buffer size
  'Returns 0 if error and 1 if success
  If MiniFmod_Init(@Music(0), 86030)  =  0  Then
    Print "Error upon initialization"
    Sleep 5000
    End 1
  End If
 
  'Start play
  MiniFmod_Play()
 
  Print "Playing song ..."
  Print "Press a key to exit"

  Dim as integer ord, row, channels, note, samp
  Dim as single mytime
  Dim as integer synchChannel
  Dim as unsigned integer inst_note
  synchChannel = 1
   
    While Inkey$ = ""
       
      'return current order 
      ord = MiniFmod_GetOrder()
     
      'return current row
      row = MiniFmod_GetRow()
     
      'return elapsed time
      mytime = MiniFmod_GetTime() / 1000
     
      Locate 11, 1
      Print "ord " & ord & " row " & row & " seconds " & mytime & "          "
     
      'return current module max. channels
      channels = MiniFmod_GetChannels()
     
      Locate 12, 1
      Print "Module Channels: " & channels & "           "
     
      'Get channel to synch
      'return sample/instrument at uinteger hi word and note on low word
      'for desired channel passed to the function
      inst_note = MiniFmod_GetSynch(synchChannel)
      samp = inst_note shr 8 'hiword = sample/inst
      note = inst_note and &hff 'loword = notes
      Locate 13, 1
      Print "Note: " & note & "           "
      Locate 14, 1
      Print "Sample Num.: " & samp & "           "

      Sleep 1
   
    Wend
   
    'Volume fade test
    dim vol as single
    dim t as integer
    vol = 1.0 'Full Volume
    t = GetTickCount()
    Print "Fade effect test..."
   
    while vol>0.0
       
        if(GetTickCount()> t+100) then
            t=GetTickCount()
            vol=vol-0.01
           
            ' the range for "vol" are:
            ' 1.0 for full volume and 0.0 no sound
            MiniFmod_SetVolume(vol)
           
        endif
       
        Locate 16, 1
        Print Using "Volume: #.##"; vol
       
    wend
 
  'Stop play
  MiniFmod_Stop()
  'Free music
  MiniFmod_Free()
  Print "Music Stopped"
  Sleep 2000
  End
 
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #28 on: June 16, 2009 »
This is a bit of psuedo code.

Code: [Select]
dim as single runningtimer, voltimer
dim as integer volduration=1000, height2=240
dim as integer effect_status, effect_running=0, effect_closing=1, effect_over=2

effect_status=effect_running

While effect_status<>effect_over
        
         runningtimer=timer()

         if effect_status=effect_closing then
            
            if( voltimer + volduration)<=runningtimer*1000.00 and musicvolume>0.0 then
                
                MiniFmod_SetVolume( MusicVolume )
                MusicVolume-=0.2
                'if MusicVolume<=0.0 then MusicVolume=0.0
                
                voltimer=runningtimer*1000.00
            end if
                
            border_size+=1
            if border_size>=height/2 then effect_status=effect_over
            
        end if
        
        if inkey=chr(27) then effect_status=effect_closing
                
        ' do effects here
        ptc_update @screenbuffer(0)
wend

I've tried with the above which is very similar to yours, however i cant seem to get on with it at all.

Perhaps, you could when you have some free time have a look into the volume stuff a bit more dude. I take it that mini fmod is a cut down version of FMOD, maybe theres clues in the bigger version.

Cheers and all the very best,
Clyde.
« Last Edit: June 16, 2009 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Freebasic MiniFmod 1.70
« Reply #29 on: June 17, 2009 »
@Clyde: please post the complete non working code or it did happen.

Seriously, just looking at your pseudo code I can't help much, for example, on above code if you aren't initializing MusicVolume = 1.0 it won't work, not sure if you are setting it up in another part of your code  ???
« Last Edit: June 18, 2009 by rbz »
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #30 on: June 18, 2009 »
appologies rbz i was in rather a hurry the other day.
Here is a better example for you to have a play with and inspect when you have a mo.

Dont know if there's issues with using a quite old version of FreeBASIC, compared to the version i have V0.20

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Freebasic MiniFmod 1.70
« Reply #31 on: June 20, 2009 »
Clyde, test this new one, I did some changes here and there and seems to be working fine (faster)

On your example, change "volume_duration" to 100

and this line:
Code: [Select]
if( volume_timer + volume_duration )<=(running_timer*1000.00) and minifmod_volume>0.0 then
to
Code: [Select]
if( volume_timer + volume_duration )<=(running_timer*1000.00) then
You don't need to clip the "minifmod_volume" variable by yourself, as there's a code in the library that does it for you and keep it in a range of 1.0 to 0.0
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #32 on: June 20, 2009 »
Thanks rbz, will give the new version a whirl.

Before I pop off, is there a command to get the current volume in order to see when it actually updates?

Muchos Gracias,
Senior Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #33 on: June 30, 2009 »
I've found something else today, a song plays nicely the first time round and then when it loops back to the beginning for the first few tracks it's all up in the air with the notes, it then settles down after about a minute or so, and plays the remaining notes hunky dori ( fine ).
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Freebasic MiniFmod 1.70
« Reply #34 on: November 27, 2010 »
coding: jwasm,masm
hobby: www.scd2003.de