Home › Forums › General › Panels, Components, Macros › waveform component example
- This topic has 31 replies, 3 voices, and was last updated 10 years, 10 months ago by msepsis.
-
AuthorPosts
-
June 2, 2013 at 2:17 pm #9497
Hi Atom, would you mind showing how to draw the waveshape in the component using data from a MemoryBlock instead of a file? I’ve been trying to but can’t seem to figure out what to do instead of the loadFromFile call you use in the demo panel.
June 2, 2013 at 3:28 pm #9498Anything from the AudioThumbnail class will work:
you can always check out the magic what() function in Lua to see what methods are available, in this case:
>>> what (panel:getWaveformComponent("modulator-3")) Object type [CtrlrWaveform] ----------------------------------------------------------------- Members: getRight: function getPropertyDouble: function copyAllExplicitColoursTo: function focusGained: function setRepaintsOnMouseActivity: function getBottom: function getMaximum: function setComponentText: function isFocusContainer: function parentHierarchyChanged: function isVisible: function setExplicitFocusOrder: function setEnd: function getAlpha: function setCentreRelative: function removeProperty: function removeChildComponent: function getComponentAt: function mouseUp: function canModalEventBeSentToComponent: function minimisationStateChanged: function setComponentID: function localAreaToGlobal: function findColour: function setFocusContainer: function setAlpha: function getTotalLength: function getComponentID: function isBroughtToFrontOnMouseClick: function click: function paint: function lookAndFeelChanged: function visibilityChanged: function getVisibleArea: function findChildWithID: function getScreenBounds: function getHashCode: function isEnabled: function getParentComponent: function getLuaBounds: function getApproximateMinMax: function removeAllChildren: function getMouseXYRelative: function getInterceptsMouseClicks: function getParentMonitorArea: function getWantsKeyboardFocus: function setSize: function hitTest: function setPropertyColour: function getScreenY: function childrenChanged: function setTopLeftPosition: function keyStateChanged: function setInterceptsMouseClicks: function getRect: function setCentrePosition: function getChildComponent: function getExplicitFocusOrder: function childBoundsChanged: function setReader: function getTopLevelComponent: function setOpaque: function colourChanged: function repaint: function getMouseClickGrabsKeyboardFocus: function getScreenX: function getY: function isMouseOver: function setLookAndFeel: function getLocalBounds: function setSourceSamplesPerThumbnailSample: function removeFromDesktop: function getWindowHandle: function getParentHeight: function getCurrentFile: function getCurrentAudioBuffer: function setMouseClickGrabsKeyboardFocus: function getBoundsInParent: function setPaintingIsUnclipped: function getIndexOfChildComponent: function contains: function addBlock: function isFullyLoaded: function getLocalPoint: function reallyContains: function getComponentMidiValue: function mouseDrag: function getX: function setPropertyDouble: function centreWithSize: function createComponentSnapshot: function setPositioner: function setVisible: function addAndMakeVisible: function loadFromFile: function isAlwaysOnTop: function isMouseButtonDown: function userTriedToCloseWindow: function setComponentMidiValue: function enablementChanged: function getParentWidth: function setBufferedToImage: function isCurrentlyBlockedByAnotherModalComponent: function getComponentText: function removeMouseListener: function addChildAndSetID: function isShowing: function keyPressed: function updateMouseCursor: function handleCommandMessage: function getPropertyInt: function isColourSpecified: function toBehind: function inputAttemptWhenModal: function reset: function getBounds: function getMouseCursor: function sendLookAndFeelChange: function isOpaque: function mouseWheelMove: function setComponentEffect: function getLookAndFeel: function setVerticalZoomFactor: function getProperties: function getComponentEffect: function exitModalState: function setBroughtToFrontOnMouseClick: function setBounds: function getMinimum: function setBoundsInset: function setWantsKeyboardFocus: function clear: function moved: function setBoundsRelative: function setStart: function getNumChannels: function toBack: function toFront: function setMidiValue: function getNumChildComponents: function getHeight: function setName: function getMidiValue: function modifierKeysChanged: function mouseDoubleClick: function setEnabled: function mouseEnter: function paintOverChildren: function setPropertyInt: function addChildComponent: function getPosition: function getProperty: function hasKeyboardFocus: function getLocalArea: function mouseMove: function paintEntireComponent: function setTopRightPosition: function addToDesktop: function proportionOfWidth: function setProperty: function getCachedComponentImage: function setPropertyString: function getMarkers: function createFocusTraverser: function __init: function getValue: function removeColour: function addKeyListener: function proportionOfHeight: function getScreenPosition: function parentSizeChanged: function focusLost: function setCachedComponentImage: function getObjectTree: function removeComponentListener: function isTransformed: function removeKeyListener: function getNumSamplesFinished: function setValue: function getPropertyString: function getPositioner: function isParentOf: function setTransform: function postCommandMessage: function addMouseListener: function getTextForValue: function localPointToGlobal: function addComponentListener: function grabKeyboardFocus: function setMouseCursor: function moveKeyboardFocusToSibling: function getComponentValue: function mouseDown: function getWidth: function resized: function setComponentValue: function broughtToFront: function isMouseOverOrDragging: function isOnDesktop: function getPeer: function setColour: function focusOfChildComponentChanged: function getTransform: function setAlwaysOnTop: function enterModalState: function isCurrentlyModal: function mouseExit: function deleteAllChildren: function setBoundsToFit: function getApproximatePeak: function setLuaBounds: function Attributes: -----------------------------------------------------------------
You can check out how what works in the Juce manual (the waveform component in Ctrlr is just an implementation of the AudioThumbnail class): http://www.rawmaterialsoftware.com/juce/api/classAudioThumbnail.html
June 2, 2013 at 9:05 pm #9512Sure that’s also possible, i’ll add that.
thanks a lot. If you get an example made it’d be great if you could send a link to a zip or something to save you some time instead of putting it in the new build, compiling the new build, uploading the new build, etc. but whatever works best for you.
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 2, 2013 at 9:23 pm #9513The panel examples are always available from the SVN repository on sf.net, it’s public and anyone can download the latest version.
June 2, 2013 at 11:06 pm #9516That should be there now, please use the latest nightly (i added some memory management so Ctrlr doesn’t leak it when using AudioFormatReaders)
June 3, 2013 at 10:44 am #9532I created a special placehold panel for all the DEMO panels with a link to the SVN repository: http://ctrlr.org/demo-panels/
June 7, 2013 at 11:28 pm #9692Thanks for posting the demo, atom. I’ve got it nearly completely implemented. I’m using 48kHz .wav files, so the more or less standard waveform contains 1024 samples, which is easily devisable by 64. The waldorf microwaves only store/transmit 64 samples. Now i just need to grab every 16th sample to get to the zero crossing at the 513th sample and pass that on to my custom component.
I’m currently playing with the 8th line in the convert script to try and make some of the byte grabbing of the imported wave’s sampleData a little more manageable.
Just so you’re aware, the header of your “convert” script contains what I believe (hope!) is a typo:
convert = function(audioFromat) if audioFormat then console ("audioFormat is valid")
Fromat 🙂
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 7, 2013 at 11:35 pm #9693oh yeah it’s a type-o, it’s the name of the variable you can put “cock” in there and just reference “cock” inside the code, no problem.
June 7, 2013 at 11:51 pm #9694right but if you put cock in there wont it get stuck if you call it occk later on?? like your code did?
Nothing actually was broke, just happened to see it was (audioFromat) then in the next line “audioFormat”, and the next line etc.
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 8, 2013 at 12:06 am #9695Question on this..
How do I get and assign every nth byte of the results of (sampleData:toHexString(1))
to variables I already have set?I’ve got:
WAVDSigned_XT_Sample01 = (sampleData:toHexString(1):getByte(1)) WAVDSigned_XT_Sample02 = (sampleData:toHexString(1):getByte(2)) WAVDSigned_XT_Sample03 = (sampleData:toHexString(1):getByte(3))
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 8, 2013 at 12:06 am #9696Well yes and no 🙂 it’s a type-o, if you put “cock” in
convert = function(cock)
then you just need to use that variable in the function, so replace audioFormat and audioFromat (if any) in the code with cock and it should work, it’s the same rule as with any other function argument.
I don’t remember if audioFormat wasn’t declare in a different lua method, and since ALL variables in Lua are global that might cause some issue. You can declare local only variables in Lua using the “local” keyword like so
convert = function(cock) local vagina = 1 -- vagina will be a local variable to this method, -- no other method will see it, so it will always -- evaluate to nil anywhere outside this method end
more details here for example: http://lua.gts-stolberg.de/en/Variablen.php in the section “Variables – Scope of application”
June 8, 2013 at 12:18 am #9699nevermind. `
WAVDSigned_XT_Sample01 = ((sampleData):getByte(1))
WAVDSigned_XT_Sample02 = ((sampleData):getByte(2))
WAVDSigned_XT_Sample03 = ((sampleData):getByte(3))
`
/facepalmwtf i need some beer.
- This reply was modified 10 years, 10 months ago by msepsis.
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
-
AuthorPosts
- The forum ‘Panels, Components, Macros’ is closed to new topics and replies.