Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Smart way to connect QML GUI objects to C++ audio processing chain?
QtWS25 Last Chance

Smart way to connect QML GUI objects to C++ audio processing chain?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlquickaudio qmlaudioc++
1 Posts 1 Posters 833 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • YosemiteY Offline
    YosemiteY Offline
    Yosemite
    wrote on last edited by Yosemite
    #1

    Okay, I am wracked with indecision!

    I'm building an audio synthesis application with a minimal "patcher" style interface, in the vein of languages like Max and Pd. A QML scroll area represents the C++ audio processing tree. Drag and drop QML items represent any single C++ audio processing unit in that tree.

    Right now, when a QML audio unit is created in the patcher window by the user, the QML item calls a Q_INVOKE method on the C++ audio processing tree. The tree instantiates an equivalent C++ audio class and passes it a pointer to the QML item. The C++ instance is connected to its QML representation via signals and slots. For example:

    //QML is created and invokes C++ method to 
    //create equivalent audio processor, passes itself
    //for signal/slot connection
        function create() {
            created = true
            graph.createItem(this, type)
        }
    
    
    //C++ synthesis tree creates the proper instance and
    //sets the pointer to QML GUI item
    void SynthGraph::createItem(QObject* gui, int type)
    {
        switch (type){
        case OSCILLATOR: {
            SynthItem* item = new Oscillator();
            item->setMyGui(gui);
            break;
        }
        default:
            break;
        }
    }
    
    //C++ class connects signals and slot for communicating
    //to its GUI representation
    void SynthItem::connectGui()
    {
        QObject::connect(myGui, SIGNAL(destroyed(QObject*)),
                         this, SLOT(requestDelete()));
    
        QObject::connect(myGui, SIGNAL(testSignal(QString)),
                         this, SLOT(testSlot(QString)));
    }
    
    
    

    But like I said, I'm freaking out! The more documentation I read, the more doubts I have. Is this sensible from a code readability and performance point of view? Should I be making the audio processing classes instantiable from QML instead? Embedding the C++ object into the corresponding QML item? Does it even matter how I do this!? :)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved