Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
use CNewFileSelector
Avatar
marclingk
Member
Members
March 25, 2021 - 8:07 pm
Member Since: April 29, 2020
Forum Posts: 17
sp_UserOfflineSmall Offline

I get a path to a sound file in plugingui. ok:

if (pControl->getTag() == 11) //openFile
{
if (pControl->getValueNormalized() == 1) {

CNewFileSelector* selector = CNewFileSelector::create(getFrame(), CNewFileSelector::kSelectFile);
if (selector)
{
selector->addFileExtension(CFileExtension("WAVE", "wav", "audio/wav"));
selector->setDefaultExtension(CFileExtension("WAVE", "wav"));
selector->setTitle("Choose An Audio File");
selector->run(this);

char WaveFile[250]; // to be defined elsewhere
strcpy(WaveFile, selector->getSelectedFile(0));

selector->forget();
}
}
return;
}

But how do I pass this path to plugincore?

Avatar
W Pirkle
Admin
March 26, 2021 - 9:38 am
Member Since: January 29, 2017
Forum Posts: 569
sp_UserOfflineSmall Offline

You will need to use a custom view to pass the string back. 

There is no plugin API that supports a single string being passed as a plugin parameter via the normal method, but you can always use a custom view to make that work.

One of the admins here (Jim) has done this already as he was trying to figure out the same issue, but I think he is on a hiatus right now. 

Will

Avatar
marclingk
Member
Members
March 26, 2021 - 11:40 am
Member Since: April 29, 2020
Forum Posts: 17
sp_UserOfflineSmall Offline

You mean with moodycamel::ReaderWriterQueue I can grab the string?

Avatar
W Pirkle
Admin
March 26, 2021 - 3:20 pm
Member Since: January 29, 2017
Forum Posts: 569
sp_UserOfflineSmall Offline

If you look in the ASPiK demo custom views project there is a custom view called CustomKnobView.

Among other things, it shows how to query a control and receive a message back from it.

void CustomKnobView::sendMessage(void* data)

{

    CustomViewMessage* viewMessage = (CustomViewMessage*)data;

    

    // --- example of messaging: plugin core send message, we acknowledge

    if (viewMessage->message == MESSAGE_QUERY_CONTROL)

    {

        if (viewMessage->queryString.compare("Hello There!") == 0)

        {

            viewMessage->replyString.assign("I'm Here!!");

            viewMessage->messageData = this; // <– example of VERY risky thing to do; not recommended

        }

    }

 

    // --->> CustomViewMessage has =operator

    dataQueue->enqueue(*viewMessage);

}

Will 

Avatar
marclingk
Member
Members
March 31, 2021 - 9:14 am
Member Since: April 29, 2020
Forum Posts: 17
sp_UserOfflineSmall Offline

Hi Will.

I managed to get the path of the file and enqueued it. But where do I dequeue it on the other side? The dequeue routines are not present.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CustomKickButton::CustomKickButton(const VSTGUI::CRect& size, IControlListener* listener, int32_t tag, CBitmap* background, const CPoint& offset)

: CKickButton(size, listener, tag, background, offset)

{

dataQueue = new moodycamel::ReaderWriterQueue<CustomViewMessage, 256>; ///< lock-free queue for incoming data, sized to 256 in length

}

 

CMouseEventResult CustomKickButton::onMouseDown(CPoint& where, const CButtonState& buttons)

{

//Marc

CNewFileSelector* selector = CNewFileSelector::create(getFrame(), CNewFileSelector::kSelectFile);

if (selector)

{

//selector->addFileExtension(CFileExtension("AIFF", "aif", "audio/aiff"));

//selector->addFileExtension(CFileExtension("AIFF", "aiff", "audio/aiff"));

selector->addFileExtension(CFileExtension("WAVE", "wav", "audio/wav"));

selector->setDefaultExtension(CFileExtension("WAVE", "wav"));

selector->setTitle("Choose An Audio File");

selector->runModal();

 

if (selector->getSelectedFile(0))

{

strcpy(WaveFile, selector->getSelectedFile(0));

newFile = true;

}

else {

strcpy(WaveFile, "");

newFile = false;

}

selector->forget();

}

 

return onMouseMoved(where, buttons);

}

 

void CustomKickButton::sendMessage(void* data)

{

CustomViewMessage* viewMessage;

 

if (newFile) {

newFile = false;

viewMessage->replyString.assign(WaveFile);

dataQueue->enqueue(*viewMessage);

}

}

Avatar
W Pirkle
Admin
March 31, 2021 - 9:36 am
Member Since: January 29, 2017
Forum Posts: 569
sp_UserOfflineSmall Offline

De-queueing is done in the PluginCore::processMessage( ) method. This is detailed in the ASPiK documentation:

http://aspikplugins.com/sdkdoc.....ner11.html

http://aspikplugins.com/sdkdoc.....l/cv9.html

http://aspikplugins.com/sdkdoc.....l/cv8.html

 

The Demo Custom View project's PluginCore::processMessage( ) shows exactly how to do this with the custom knob control. It is in both the "With FFT" and "Without FFT" projects in the ASPiK SDK's samples/ folder. 

      if (messageInfo.inMessageString.compare("CustomKnobView") == 0)

        {

            // --- (1) get the custom view interface via incoming message data*

            if (knobView != static_cast<ICustomView*>(messageInfo.inMessageData))

                knobView = static_cast<ICustomView*>(messageInfo.inMessageData);

            

            if (!knobView) return false;

            

            // --- send the view a message

            VSTGUI::CustomViewMessage knobMessage;

            knobMessage.message = VSTGUI::MESSAGE_QUERY_CONTROL;

            knobMessage.queryString.assign("Hello There!");

            

            // --- send the message

            knobView->sendMessage(&knobMessage);

                        

            // --- check the reply string; the messgageData variable contains a pointer to the object (DANGEROUS)

            const char* reply = knobMessage.replyString.c_str();

            printf("%s", reply);

            

            // --- DO NOT DO THIS!!! (but it is possible)

            //CAnimKnob* customKnob = static_cast<CAnimKnob*>(knobMessage.messageData);

            

            // --- registered!

            return true;

        }

Avatar
marclingk
Member
Members
April 1, 2021 - 5:54 am
Member Since: April 29, 2020
Forum Posts: 17
sp_UserOfflineSmall Offline

Ok, thank you Will. Now I did it and it works perfectly.

The only question, if I can optimize the CPU-power:

Now I am asking in the PING routine, if there is a new file-name. This is quite often. Is that a problem? Or is there a way to catch messages from the GUI without repeating to ask for?

Avatar
marclingk
Member
Members
April 11, 2021 - 9:30 pm
Member Since: April 29, 2020
Forum Posts: 17
sp_UserOfflineSmall Offline

New problem with CNewFileSelector

Living in Germany, I have sometimes special characters in file name.

CNewFileSelector* selector = CNewFileSelector::create(getFrame(), CNewFileSelector::kSelectFile);

selector->getSelectedFile(0) returns a UTF8StringPtr

How do I use this pointer to open the file?

It works with standard characters but not with special ones. Example

"D:\\Music\\TimeFreezerSounds\\Marc Lingk\\Phrasen 11 Flöten.wav"

But it should be

"D:\\Music\\TimeFreezerSounds\\Marc Lingk\\Phrasen 11 Flöten.wav"

I must cast it to platform string but how?

 
Avatar
W Pirkle
Admin
April 14, 2021 - 4:16 pm
Member Since: January 29, 2017
Forum Posts: 569
sp_UserOfflineSmall Offline
Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Chaes: 51

Skyler: 48

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

clau_ste: 39

jim: 34

JimmyM: 33

Gwen: 32

Member Stats:

Guest Posters: 1

Members: 691

Moderators: 1

Admins: 5

Forum Stats:

Groups: 13

Forums: 41

Topics: 754

Posts: 2881

Newest Members:

Niklas, Wutru, Tim Campbell, Danny Jonel, Valentin, joelr, PseudoSpaceMusic, duo.dirtykidz, Paul, Reakenzo

Moderators: W Pirkle: 569

Administrators: Tom: 74, JD Young: 80, Will Pirkle: 0, W Pirkle: 569, VariableCook: 3