Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transcode() as a Bottleneck #2

Open
Ignotus-mago opened this issue Jun 28, 2024 · 1 comment
Open

Transcode() as a Bottleneck #2

Ignotus-mago opened this issue Jun 28, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Ignotus-mago
Copy link
Owner

(copied from PixelScanner Issues)

Should the transcode(int) and transcode(float) methods be called everywhere that transcoding happens in other methods in PixelAudioMapper?

        public int transcode(float val) {
		 float vout = map(val, -1.0f, 1.0f, 0, 255);
		 return Math.round(vout);
	 }

	public float transcode(int val) {
		 float vout = map(val, 0, 255, -1.0f, 1.0f);
		 return vout;
	 }

We do this mapping almost everywhere. If we want to use different ranges for the img[] and sig[] arrays, using transcode as a bottleneck would mean we only have to override these two methods to change behavior in all methods that map audio to RGB or RGB to audio. The overhead of a method call should be minimal. SO, I guess the question is in what circumstances would overriding be useful?

Perhaps we want to make the library only work for RGB [0, 255] and audio (-1.0..1.0)? Could it easily handle 16 bit channels, for example, or a much wider signal amplitude range, with just a change to transcode?

Well, no. Bitshifting is also used throughout the RGB math, but that could be overridden too, I think. Changing the audio range would be simpler. For example, we could handle 5 volt peak-to-peak signals without normalizing them to audio range. Is that useful?

@Ignotus-mago Ignotus-mago added the question Further information is requested label Jun 28, 2024
@Ignotus-mago
Copy link
Owner Author

Ignotus-mago commented Jul 3, 2024

I recommend creating a branch with transcode() (or renamed transcodeInt(), transcodeFloat() methods) used as a bottleneck to see how well it works. Not a high priority, but should be tried before releasing the library. How does it affect speed? How useful is it really?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant