Plug'n Script: Trouble with importing a wav file

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS

Post

i'm having trouble importing the wav-file called "PinkNoise44100.wav", a 24bit mono wav-file on a 44100 samplerate of 1sec. In the following code i show what i try to do to import it. The convertToUnix-method is just copied from the presets. I tried with and without. Same for the way i structure my path. I tried this, the absolute path, but also relative paths. No matter what i do, my output is "couldn't make some noise". Does anyone see my error or can give me tipps on how to debug situations like this better? Yes, the wav-file is located in the same folder as the script.

Code: Select all

string path = scriptFilePath;
WaveFileData waveFileData;
path = path.substr(0, path.findFirst("main.cxx", 0))
  + "PinkNoise44100.wav";
convertToUnix(path);
print(path);
if(waveFileData.loadFile(path))
  setBuffer(waveFileData.interleavedSamples);
else
  print("couldn't make some noise");
  

Post

ilya helped me to find out that the absolute paths are indeed correct by suggesting i should just try to import and read the file as strings first, which sort of worked i guess^^. it produces some weird characters as output which is what can be expected when importing a wav-file like that i guess. now the only question left is why WaveFileData can't import the file like this. i am certainly missing something... but what?

Post

I think you should go into WaveFile.hxx and test how it all goes there inside .loadFile and related methods. I usually just do "print" from some points inside the file to see if it's there or not.

Post

good point. so i just tried to put some prints in the loadFile-method and here's what i found:

Code: Select all

bool ok = false;
        // open the file
        file f;
        if(f.open(filePath,"r")>=0)
        {
            // read the header
            WaveFileHeader header;
            if(header.read(f))
            {
                ok=true;
this is part of the code in that method. when i put a print() after if(f.open(filePath,"r")>=0) it works. so apparently the file can be opened.

but when i put a print before ok=true; then it doesn't work, which implies that header.read(f) is not true. so the WaveFileHeader header fails to interpret the file.

in the header-object i found out that it fails at this part of the code:

Code: Select all

tempString=f.readString(4);
                if(tempString=="fmt ")
                {
                    uint64 fmtSize = f.readUInt(4);
                    // ....
tempString seems not to be "fmt" at that point

Post

i just wonder why anything would be missing in this wav-file in the first place. i created the pink noise with audacity's pink noise generator, then imported that into cubase to normalize and lowcut the data and exported a new file from there. i think it can be expected that steinberg knows what to include into a wav-file, so i suspect that something about this wav-reader maybe isn't up to date with current wav-file formats or something? but the problem is i'm really no expert on that

Post

Image

ok actually it was really cubase' fault. i changed the export settings to this and then it worked, lol^^ i don't know which of these made the difference but now it works so i guess i'm fine with that

Post

Great that you've figured it out!

Post

not without your help. sometimes the hardest aspect about plug'n script seems to be that it doesn't have the most active community, but you're always there.

Post

:tu:

Post

The wav file reader class is very simple, so it will indeed not read all crazy types of wav files. :-)

Post

What constitutes a "crazy" type of wave file?

Looking at the header reading, it looks like any BWF headers will cause it to fail. That's a bummer, as a lot of sample packs include BWF headers. It took me a while to figure out that's what was going on - and after I resaved the samples without BWF headers, it loaded fine.

I wonder if anybody by now has taken a stab at skipping over BWF headers?

Post Reply

Return to “Blue Cat Audio”