waveform component example

Home Forums General Panels, Components, Macros waveform component example

Viewing 12 posts - 21 through 32 (of 32 total)
  • Author
    Posts
  • #9497
    Hecticcc
    Participant
      • Topics: 25
      • Replies: 160
      • Total: 185
      • ★★

      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.

      #9498
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        Anything 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

        #9512
        msepsis
        Participant
          • Topics: 219
          • Replies: 732
          • Total: 951
          • ★★★

          Sure 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

          #9513
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            The panel examples are always available from the SVN repository on sf.net, it’s public and anyone can download the latest version.

            #9516
            atom
            Keymaster
              • Topics: 159
              • Replies: 2945
              • Total: 3104
              • ★★★★★

              That should be there now, please use the latest nightly (i added some memory management so Ctrlr doesn’t leak it when using AudioFormatReaders)

              #9532
              atom
              Keymaster
                • Topics: 159
                • Replies: 2945
                • Total: 3104
                • ★★★★★

                I created a special placehold panel for all the DEMO panels with a link to the SVN repository: http://ctrlr.org/demo-panels/

                #9692
                msepsis
                Participant
                  • Topics: 219
                  • Replies: 732
                  • Total: 951
                  • ★★★

                  Thanks 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

                  #9693
                  atom
                  Keymaster
                    • Topics: 159
                    • Replies: 2945
                    • Total: 3104
                    • ★★★★★

                    oh 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.

                    #9694
                    msepsis
                    Participant
                      • Topics: 219
                      • Replies: 732
                      • Total: 951
                      • ★★★

                      right 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

                      #9695
                      msepsis
                      Participant
                        • Topics: 219
                        • Replies: 732
                        • Total: 951
                        • ★★★

                        Question 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

                        #9696
                        atom
                        Keymaster
                          • Topics: 159
                          • Replies: 2945
                          • Total: 3104
                          • ★★★★★

                          Well 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”

                          • This reply was modified 10 years, 10 months ago by atom.
                          • This reply was modified 10 years, 10 months ago by atom.
                          #9699
                          msepsis
                          Participant
                            • Topics: 219
                            • Replies: 732
                            • Total: 951
                            • ★★★

                            nevermind. `
                            WAVDSigned_XT_Sample01 = ((sampleData):getByte(1))
                            WAVDSigned_XT_Sample02 = ((sampleData):getByte(2))
                            WAVDSigned_XT_Sample03 = ((sampleData):getByte(3))
                            `
                            /facepalm

                            wtf 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

                          Viewing 12 posts - 21 through 32 (of 32 total)
                          • The forum ‘Panels, Components, Macros’ is closed to new topics and replies.
                          There is currently 0 users and 84 guests online
                          No users are currently active
                          Forum Statistics
                          Threads: 2,495, Posts: 17,374, Members: 77,605
                          Most users ever online was 12 on January 22, 2019 3:47 pm
                          Ctrlr