Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 665349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:41:54+00:00 2026-05-13T23:41:54+00:00

I have an audio project I’m working on using BASS from Un4seen. This library

  • 0

I have an audio project I’m working on using BASS from Un4seen. This library uses BYTES mainly but I have a conversion in place that let’s me show the current position of the song in Milliseconds.

Knowing that MS = Samples * 1000 / SampleRate
and that Samples = Bytes * 8 / Bits / Channels

So here’s my main issue and it’s fairly simple… I have a function in my project that converts the Milliseconds to TimeCode in Mins:Secs:Milliseconds.

Public Function ConvertMStoTimeCode(ByVal lngCurrentMSTimeValue As Long)
        ConvertMStoTimeCode = CheckForLeadingZero(Fix(lngCurrentMSTimeValue / 1000 / 60)) & ":" & _
        CheckForLeadingZero(Int((lngCurrentMSTimeValue / 1000) Mod 60)) & ":" & _
        CheckForLeadingZero(Int((lngCurrentMSTimeValue / 10) Mod 100))
End Function

Now the issue comes within the Seconds calculation. Anytime the MS calculation is over .5 the seconds place rounds up to the next second. So 1.5 seconds actually prints as 2.5 seconds. I know for sure that using the Int conversion causes a round down and I know my math is correct as I’ve checked in a calculator 100 times. I can’t figure out why the number is rounding up. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:41:54+00:00Added an answer on May 13, 2026 at 11:41 pm

    There is a flaw in your seconds conversion logic. For instance, suppose you want to convert 1500 ms. Your code to calculate seconds:

    Int((lngCurrentMSTimeValue / 1000) Mod 60)
    

    Would return 2. 1500 ms is not over two seconds! To calculate seconds, perform integer division (the “\” operator) of the milliseconds by 1000:

    (lngCurrentMSTimeValue \ 1000) Mod 60
    

    This returns 1 as expected. The following function is all you need. It even eliminates the need for your CheckForLeadingZero function by using the built-in Format function:

    Public Function ConvertMStoTimeCode(ByVal lngCurrentMSTimeValue As Long)
    
      Dim minutes As Long
      Dim seconds As Long
      Dim milliseconds As Long
    
      minutes = (lngCurrentMSTimeValue / 1000) \ 60
      seconds = (lngCurrentMSTimeValue \ 1000) Mod 60
      milliseconds = lngCurrentMSTimeValue Mod 1000
    
      ConvertMStoTimeCode = Format(minutes, "00") & ":" & Format(seconds, "00") & _
        ":" & Format(milliseconds, "000")
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working on a few projects using audio and images from
I have one audio file captured from my iphone. I want to upload this
The project that I'm working on uses a commercially available package to route audio
I have a directory /sdcard/audio in the project. This directory contains some audio (wav)
I have been encountering this error for my project, which involves working with Digital
I have been working on reading in an audio asset using AVAssetReader so that
Hi i have a audio player project, but I'd like to change control items
I have an Audio app using AVAudioPlayer on iOS. Whenever music is playing my
I have an audio file. I want to segment into 10 seconds each using
Anyone have experience playing audio (right now specifically mp3s) with python using a any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.