SC can't open or read files

Hi,
I’m trying to open a wav file in a buffer and keep getting errors saying SC can’t open or find the file.
This is on Windows 10 so I use the \ in the file directory. In the error message SC shows the whole directory without any ‘’ to separate things, I tried adding the Platform.resourceDir +/+ before the file path and still got the same errors.

I also tried changing the \ to a / and same error.

I tried making the \ a double \ and then when I got the error it shows the file path with \ in between the proper places but it still can’t open the file.

The code is as follows:
b = Buffer.readChannel(s,“C:\Users\44774\Desktop\Autobot\wubsquare8.wav”, startFrame:0, numFrames: -1);

I initially had not included the start and end frames and tried adding them to see if that was what was causing the error.

I’m guessing this is just some sort of syntax error on my part??

I’m using SC version 3.11.2

Any help would be greatly appreciated!

Hello

You need to use two backslashes because \ is a special character.

Try

 b = Buffer.readChannel(s,“C:\\Users\\44774\\Desktop\\Autobot\\wubsquare8.wav”, startFrame:0, numFrames: -1);

Best regards

Geoffroy

It’s giving me a new error with the \ I also tried changing the filename to exclude the .wav because sometimes windows is weird about including the file suffix and got the same error again.

The error is:

ERROR: syntax error, unexpected SYMBOL, expecting ‘)’
in interpreted text
line 1 char 38:

b = Buffer.readChannel(s,“C:\Users\44774\Desktop\Autobot\wubsquare8”, startFrame:0, numFrames: -1);
^^^^^^

ERROR: Command line parse failed
-> nil

The little up carrots ^^^^^^ in the error message are aligned underneath the line \Users\4

Leave it to me to struggle with the simplest thing

The quote marks in all code example in this thread are using curly typographic quotes instead of straight ASCII quotes. Strings must be delimited using straight quotes.

hjh

1 Like

I tried running the code again to load the sample wav file into a buffer.
It didn’t work.

I tried converting the .wav file to an .aiff file because maybe there was something to do with the format of the .wav file and I also moved the path to my desktop in case there was some sort of permissions issue with the documents folder. It seems as though SuperCollider can find the file path now however it says the following error message:

File ‘C:\Users\44774\Desktop\stuff and things\Autobot’ could not be opened: System error : Access is denied.

I tried temporarily turning off my anti-virus software and checking the permissions of the folders and my account has full access (I mean I created the folders so I should) as an admin.

Has anyone else had issues getting SC to load a sound file into a buffer this way?
Is this purely a windows 10 problem or an issue with this version of SC?

Are you saying the formatting is incorrect in just this post or do I need to apply special formatting to my code in the SuperCollider IDE?

I would have thought the IDE text was all in ASCII by default??

supercollider quotes are "

your

should probably be

the editor will accept non-ascii (unicode probably) as well as ascii but you need to type in the right quotes or else sclang will not accept the syntax

I’ve tried changing to ascii quotes and it still says it can’t find the file :confounded:

It looks as though it’s finally working!

I moved the file to a folder I created in the user support directory for SuperCollider and then changed the quotes to ascii.

I think the issue was that at first I had the file name listed without the extension, then I added the extension to the file name and added the file extension to the file path in the code and this must have created a conflict.

In the first instance SC needed the file extension, ascii quotes, and since I’m on windows the path needed double \ in the path file.

The final working code looks like this:

b = Buffer.readChannel(s,  "C:\\Users\\44774\\AppData\\Local\\SuperCollider\\Tables\\wubsquare.wav", startFrame:0, numFrames: -1);

The wav file is simply named wubsquare and I included the file extension in the code.

glad you sorted it out!

Thanks!
I only solved 1/3 of what I’m actually trying to do with the file but at least I got that settled.
Thank you for your help!

That’s OK but not strictly necessary. The file can be anywhere in your system.

The Windows hides file explorer file extensions by default… maybe friendlier, but if you’re going to do any programming, you’ll need to see the real, complete filename.

If the extension was hidden and then you added the extension by renaming in 5th explorer, then you’d have Autobot.aiff.aiff in the file system – it’s very confusing for programming when the extensions are hidden. Make sure to show them.

I’d bet it’s named wubsquare.wav and the explorer is lying to you by showing only wubsquare.

Also you can use forward slashes: "C:/Users/44774/AppData..."

Also you can drag a file from the explorer into the code window, and the IDE will insert the correct path string.

hjh

Blockquote
Also you can drag a file from the explorer into the code window, and the IDE will insert the correct path string.

Woa, that’s groovy. Thanks for sharing!
And thanks for pointing out your suggestions earlier!