Horizontal Filmstrip VU meter
-
@Lindon Hi lindon thank you. But this method is not the same method in my project.
In my project (attached above), this code is for vertical filmstrip. Can we convert it to horizontal filmstrip please?
const var OutputGain = Synth.getEffect("OutputGain"); inline function createFilmStripVuMeter_Left_Output(name, x, y, isLeft) { local widget = Content.addPanel(name, x, y); Content.setPropertiesFromJSON(name, { "width": 151, // this uses the exact dimensions of one filmstrip "height": 73, "opaque": true // opaque is important in order to increase the drawing performance }); // Put the image in your image folder widget.loadImage("{PROJECT_FOLDER}LEDVUMeter01.png", "filmstrip"); widget.data.value = 0.0; widget.data.isLeft = isLeft; // Set the initial image widget.setImage("filmstrip", 0, 0); widget.setTimerCallback(function() { // Get the peak value from the master output var newValue = OutputGain.getCurrentLevel(true); if(newValue > this.data.value) this.data.value = newValue; else // Just decay the current value (0.92 controls the decay time) this.data.value = this.data.value * 0.92; // Calculate the filmstrip index // this must be an integer value // 84 is used instead of 128 because 84 is ~0dB which is // more accurate for this example filmstrip var index = parseInt(this.data.value * 84.0); // If you just want to paint one image, // you don't need the paint routine, but // just use this method // the yOffset is index * heightOfFilmstrip this.setImage("filmstrip", 0, index * 73); }); widget.startTimer(30); return widget; };
-
@Steve-Mohican
this.setImage("filmstrip", 0, index * 73);
What if you just reverse x and y ;)
-
@Steve-Mohican - then yo should make a horizontal png...
-
Hmmm something's not clear, do you want the filmstrip to extend horizontally or the VUmeter to be horizontal? not the same thing...
-
Sorry for lack of info.
My filmstrip image is stitched horizontally. Actually I can't stitch it vertically because the height of the stitched image will be soo huge. It is better to stitch a vertical VU filmstrip image horizontally. You can see the image in the project file.
So the VU meter will be vertical but filmstrip image is horizontally stsitched.
I think this code is for vertically stitched filmstrips. When I swap x & y it didn't work. The solution must be so simple but I can't see it guys.
-
@Steve-Mohican So swapping x and y should work, have you adapted all other properties (index nb, width, height...)?
-
@Steve-Mohican so you want this sort of thing no?
heres the png I use:
not really so big...uses 106 images stacked vertically.. to cover the dB range -100dB to +6dB
-
Apparently, there seems to be a bug when using Xoffset making horizontal filmstrip unusable...
-
@Lindon said in Horizontal Filmstrip VU meter:
@Steve-Mohican so you want this sort of thing no?
heres the png I use:
No, my VU Meter will be like this (vertical):
And my image strip is this (stitched horizontally):
-
@ustk said in Horizontal Filmstrip VU meter:
Apparently, there seems to be a bug when using Xoffset making horizontal filmstrip unusable...
I think so too mate.
-
@Steve-Mohican So I corrected the bug, but it works using a hack for the Xoffset (it can't be 0, minimum 1). This is because the way the API is made gives a priority to check X before Y.
The way I would do it is
setImage(String imageName, bool isHorizontal, int offset)
Might not break compatibility, knowing that no one could have used a horizontal filmstrip before.
Abool isHorizontal
would be0
in older projects anyway. @Christoph-Hart ?
Working on it... -
@Steve-Mohican said in Horizontal Filmstrip VU meter:
@Lindon said in Horizontal Filmstrip VU meter:
@Steve-Mohican so you want this sort of thing no?
heres the png I use:
No, my VU Meter will be like this (vertical):
And my image strip is this (stitched horizontally):
then I've already sent you a snippet with it working...
-
@Christoph-Hart Here's a fix that is retro compatible (as long as no one as tried to use xOffset but this shouldn't be the case, otherwise it shouldn't have been broken)
Although before making a pull request, I don't know how to properly initialize theauto img
variable, I'm sure I did it dirty...void ScriptingApi::Content::ScriptPanel::setImage(String imageName, bool isHorizontal, int offset) { jassert_locked_script_thread(getScriptProcessor()->getMainController_()); paintRoutine = var(); usesClippedFixedImage = true; Image toUse = getLoadedImage(imageName); auto b = getPosition().withPosition(0, 0); auto img = toUse; int w = 0; int h = 0; if (isHorizontal) { double ratio = (double)b.getWidth() / (double)b.getHeight(); h = toUse.getHeight(); w = (int)((double)h * ratio); offset = jmin<int>(offset, toUse.getWidth() - w); img = toUse.getClippedImage(Rectangle<int>(offset, 0, w, h)); } else { double ratio = (double)b.getHeight() / (double)b.getWidth(); w = toUse.getWidth(); h = (int)((double)w * ratio); offset = jmin<int>(offset, toUse.getHeight() - h); img = toUse.getClippedImage(Rectangle<int>(0, offset, w, h)); } if (auto drawHandler = getDrawActionHandler()) { drawHandler->beginDrawing(); drawHandler->addDrawAction(new ScriptedDrawActions::drawImageWithin(img, b.toFloat())); drawHandler->flush(); } }
-