



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?
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
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Â


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);
}
}
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;
    }


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?
Looks like Arne answered your question here:
https://forums.steinberg.net/t/cnewfileselector-open-file-name-with-special-characters/711688/10
WillÂ
Most Users Ever Online: 152
Currently Online:
4 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Chaes: 56
Skyler: 48
StevieD: 46
Derek: 46
Frodson: 45
Peter: 43
TheSmile: 43
Nickolai: 43
clau_ste: 39
jeanlecode: 37
Member Stats:
Guest Posters: 1
Members: 775
Moderators: 1
Admins: 6
Forum Stats:
Groups: 13
Forums: 42
Topics: 846
Posts: 3353
Moderators: W Pirkle: 690