Results 1 to 7 of 7

Thread: TBASS_ChannelSeconds2Bytes not working?

  1. #1
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    53
    Posts
    248
    Rep Power
    40

    TBASS_ChannelSeconds2Bytes not working?

    Hello everybody,

    I want to start playing a mp3 file from 10 seconds, but TBASS_ChannelSeconds2Bytes doesn't seem to work. What am I doing wrong?


    Uses "TBASS", "CONSOLE" 
    
    function TBMain()
      Dim Channel    As DWord  
      Dim SamChannel As DWord       
    
    
      If TBASS_Init(-1, 44100, 0, 0, 0) = 0 Then Stop    
     
      Channel = TBASS_StreamCreateFile(%TBASS_FALSE,"song.mp3", 0, 0, %TBASS_STREAM_PRESCAN ) 
      TBASS_ChannelSetPosition(Channel, TBASS_ChannelSeconds2Bytes ( Channel, 10) ) 
      
      TBASS_ChannelPlay(Channel, %TBASS_TRUE)
        
      WaitKey 
    
    
      TBASS_Free
    end function
    
    Also I am missing TBASS_ChannelSetSync in the documentation, is that function not available in ThinBasic?
    Last edited by martin; 05-11-2014 at 12:50.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Hi Martin,

    yes, there is something wrong with TBASS_ChannelSeconds2Bytes function.
    I'm checking what's wrong.

    In any case check TBASS_ChannelPlay: second parameter must be %TBASS_FALSE otherwise it will always start from the beginning.

    I will let you know about TBASS_ChannelSeconds2Bytes

    Ciao
    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

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    I got crazy but I should have fixed.

    Despite BASS documentation of BASS_ChannelSeconds2Bytes says it returns a QUAD, in reality it returns a DWORD.

    Attached a fixed thinBasic_TBASS.DLL library. To use unzip thinBasic_TBASS.DLL into \thinBasic\Lib\ directory replacing your current one.
    Fix will be present in next thinBasic release.

    Script example:
    Uses "TBASS", "CONSOLE" 
    Function TBMain()
      Dim Channel     As DWord 
      Dim SamChannel  As DWord
      Dim CurrentPos_Bytes    As Quad      
      Dim CurrentPos_Seconds  As Double      
     
     
      If TBASS_Init(-1, 44100, 0, 0, 0) = 0 Then Stop   
      
      '---Attention
      '---"BlackBox.mp3" is inside the following directory: \thinBasic\SampleScripts\TBASS\
      '---
      Channel = TBASS_StreamCreateFile(%TBASS_FALSE, "BlackBox.mp3", 0, 0, %TBASS_STREAM_PRESCAN )
      
      PrintL "TBASS_GetVersion.....................:", Hex$(TBASS_GetVersion)
      PrintL "Channel..............................:", Channel
      PrintL "TBASS_ChannelGetLength...............:", TBASS_ChannelGetLength(Channel)
      PrintL "TBASS_ChannelSeconds2Bytes.15........:", TBASS_ChannelSeconds2Bytes (Channel, 15)
      PrintL "Error................................:", TBASS_ErrorGetCode & " " & TBASS_ErrorToString(TBASS_ErrorGetCode)
      PrintL "TBASS_ChannelBytes2Seconds 1700000...:", Format$(TBASS_ChannelBytes2Seconds (Channel, 1700000), "#0.00")
      PrintL "Error................................:", TBASS_ErrorGetCode & " " & TBASS_ErrorToString(TBASS_ErrorGetCode)
      PrintL "TBASS_ChannelSetPosition.............:", TBASS_ChannelSetPosition(Channel, TBASS_ChannelSeconds2Bytes (Channel, 15) ) 
      PrintL "Error................................:", TBASS_ErrorGetCode & " " & TBASS_ErrorToString(TBASS_ErrorGetCode)
      PrintL 
      PrintL 
      PrintL "---Press any key to stop. Execution will stop at the end of the ChannelPlay---"
       
      TBASS_ChannelPlay(Channel, %TBASS_FALSE)
      
      While Len(Console_InKeyB) = 0 And TBASS_ChannelIsActive(Channel)
        CurrentPos_Bytes    = TBASS_ChannelGetPosition(Channel)
        CurrentPos_Seconds  = TBASS_ChannelBytes2Seconds(Channel, CurrentPos_Bytes)
        
        PrintAt "Current position in bytes............: " & CurrentPos_Bytes                                        , 1, 15
        PrintAt "Current position in seconds..........: " & Format$(CurrentPos_Seconds, "#0.00")                    , 1, 16
        PrintAt "Current position in seconds to bytes.: " & TBASS_ChannelSeconds2Bytes(Channel, CurrentPos_Seconds) , 1, 17
      Wend  
     
      TBASS_Free
    
    
    End Function
    
    Attached Files Attached Files
    Last edited by ErosOlmi; 08-11-2014 at 10:38.
    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

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Quote Originally Posted by martin View Post
    Also I am missing TBASS_ChannelSetSync in the documentation, is that function not available in ThinBasic?
    That function requires a callback (a pointer to compiled function) and so far thinBasic script functions cannot be used in those cases.
    Maybe in future thinBasic releases I will find a way to link script functions pointers to compiled code.
    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. #5
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    53
    Posts
    248
    Rep Power
    40
    Hi Eros,

    Thanks A LOT for fixing this problem so fast. It works perfect now!

    Martin

  6. #6
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    53
    Posts
    248
    Rep Power
    40
    Forgive me, one more request:
    Is it possible to add TBASS_StreamCreateURL ?
    http://www.un4seen.com/doc/#bass/BAS...CreateURL.html

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    I will see what I can do. That function has a callback used to get the progression of the loading.
    Maybe I will just ignore for the moment.
    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

Similar Threads

  1. tB + VS working together?
    By LCSims in forum thinBasic General
    Replies: 3
    Last Post: 10-07-2012, 21:28
  2. TGA files not working
    By Michael Clease in forum TBGL General
    Replies: 15
    Last Post: 13-06-2009, 11:57
  3. What are you working on?
    By Michael Clease in forum TBGL General
    Replies: 17
    Last Post: 02-02-2008, 07:11
  4. FreeBasic SDK: first working example
    By ErosOlmi in forum Module SDK (Freebasic version)
    Replies: 14
    Last Post: 23-09-2007, 08:26

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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