Skip to content

Conversation

betpowo
Copy link
Contributor

@betpowo betpowo commented Jun 1, 2025

in chart editor songs would end early because guess what.... the sound length was rounded for whatever reason meaning like a 0.9 second song wouldnt even be chartable lmfao

but hopefully its fixed now ..... feel free to test with long ass songs cus that was the whole purpose of changing the sound length stuff in the first place .... i dont have any long ass songs to test .....

in chart editor songs would end early because guess what.... the sound length was rounded for whatever reason
meaning like a 0.9 second song wouldnt even be chartable lmfao

but hopefully its fixed now ..... feel free to test with long ass songs cus that was the whole purpose of changing the sound length stuff in the first place .... i dont have any long ass songs to test .....
@NeeEoo
Copy link
Contributor

NeeEoo commented Jun 1, 2025

Make sure this works on haxe 4.2.5 and haxe 4.3.6

// return Std.int(samples / __buffer.sampleRate * 1000);
var samples = (Int64.make(0, __buffer.data.length) * Int64.ofInt(8)) / Int64.ofInt(__buffer.channels * __buffer.bitsPerSample);
var value = samples / Int64.ofInt(__buffer.sampleRate) * Int64.ofInt(1000);
var div = Int64.divMod(samples * 1000, Int64.ofInt(__buffer.sampleRate));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not samples * Int64.ofInt(1000)
Wouldnt there be a risk of overflow otherwise

@moxie-coder
Copy link
Contributor

Make sure this works on haxe 4.2.5 and haxe 4.3.6

or 4.3.7 because that came out not long ago

@Circuitella
Copy link

hyds8edfnty11.jpg

No way

var samples = (Int64.make(0, __buffer.data.length) * Int64.ofInt(8)) / Int64.ofInt(__buffer.channels * __buffer.bitsPerSample);
var value = samples / Int64.ofInt(__buffer.sampleRate) * Int64.ofInt(1000);
var div = Int64.divMod(samples * 1000, Int64.ofInt(__buffer.sampleRate));
var value = (div.quotient + (div.modulus / __buffer.sampleRate));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the value returned from this matches correctly, between normal openfl and your pr.
And show the results,
Because i am feeling a bit suspicious of the (div.modulus / sampleRate)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've actually tested this and it does match correctly, i was doing a trace like

trace('og openfl: $ogval');
trace('my calc: $myval');

tested on a 20.974s audio file, i managed to get both results to show the same number (20974)
reason it was rounding to 20000 was because (i64 / int) only returns the quotient of the division:

	/**
		Returns the quotient of `a` divided by `b`.
	**/
	@:op(A / B) public static inline function div(a:Int64, b:Int64):Int64
		return divMod(a, b).quotient;

haxe.Int64, line 320

which of course would be 20, the modulus corresponds to the decimal of the wanted number (.974)
and since were multiplying the "whole parts" of the division by 1000...... well..... thats what was causing the bug lol
so i had to implement the modulus myself because an average division on Int64 only uses like the "floored" value of the wanted result ;-;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet I'll send this in for internal review!

you are not part of the team lol

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will respectfully need you to shut it ❤️

Copy link
Contributor

@moxie-coder moxie-coder Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will respectfully need you to shut it ❤️

IMG_8268

nah

@CodenameCrew CodenameCrew deleted a comment from RaynFoxDragon Jun 1, 2025
@NeeEoo NeeEoo merged commit f989a1b into CodenameCrew:main Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants