Is relative directories possible in C++11?

I’m trying to convert: "res/sample.wav" to "c://...documents/rack/plugins/fault/res/sample.wav" as that appears to be how dr_wav() wants the file - tho I don’t see why?

So I’m using pSampleData2 = drwav_open_and_read_file_f32(fs::absolute(p).string().c_str(), &c, &sr, &sc);

but

#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;

only works in C17 How else can I access a relative filename, so default samples are available?

thanks

I assume you mean C++11 rather than C11 so I’ve edited the thread’s title.

You can’t use filesystem:: in C++11, although the Rack 2 API will add system::getAbsolute().

However, dr_wav can load relative paths just fine, so I would look into that. You don’t need to pass absolute paths.

I assume you mean C++11 rather than C11 so I’ve edited the thread’s title.

– yes, thank you

You can’t use filesystem:: in C++11, although the Rack 2 API will add system::getAbsolute().

– As per investigation, understood.

However, dr_wav can load relative paths just fine, so I would look into that. You don’t need to pass absolute paths.

– That’s what it looks like in the docs - the comments in the code. I’m hoping so, because I thought I’d be able to submit the plugin today thinking I “only” have to convert my paths.

“I only have to” is as dangerous a phrase as “I just have to”

I tried using the location of the plugin as the relative base because of numerous mentions of “res/filename” in the code but so far, no success.

But your confimation is what I need to return to that line of investigation

thanks

If you’re trying to access plugin assets, although it’s possible for asset::plugin("res/filename") to return a relative path (if for example the user sets their Rack user dir to "."), it’s usually an absolute path. You shouldn’t pass the literal string "res/filename" to dr_wav because Rack’s working directory is not set to your plugin directory. You should use the path returned by asset::plugin("res/filename").

1 Like

Excellent. Thank you very much. asset.plugin() was the missing piece.

Removing a function was really important :slightly_smiling_face:

For aestetic purposes I don’t want the ability to load new samples. The ability to cycle through the folder content, means you can add samples as a ‘hack’ by placing more in the correct folders.

I think it’s ready for MVP publishing. I’ll start the process tomorrow. It’s a really a simple device, but it will be the basis for some Machine Learning stuff (I hope)

You can mark a thread as solved by clicking Solution on a post. No need to edit the title with a fake-tag.