[Csnd] filevalid opcode question

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] filevalid opcode question

Rene-2
Hello list,

I am on linux, csound 6.11

It seems that filevalid opcode only detect if file exit or not, but gives init error is the file exist but is not valid.
 
For example test_filevalid.csd gives

INIT ERROR in instr 1: diskin2: /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file (File contains data in an unknown format.)

and i1 stops!

is it normal?
I wish to use filevalid opcode to prevent the end user to make mistake when browsing waves files.

Regards,
René
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

test_filevalid.csd (952 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

zappfinger
Soundfont files (SF2) cannot be played with the diskin opcodes. You should use the 'sf' family of opcodes for that, e.g. sfload()

Richard

2018-05-25 11:21 GMT+02:00 Rene <[hidden email]>:
Hello list,

I am on linux, csound 6.11

It seems that filevalid opcode only detect if file exit or not, but gives init error is the file exist but is not valid.
 
For example test_filevalid.csd gives

INIT ERROR in instr 1: diskin2: /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file (File contains data in an unknown format.)

and i1 stops!

is it normal?
I wish to use filevalid opcode to prevent the end user to make mistake when browsing waves files.

Regards,
René
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

Rene-2
Yes, sf2 cannot be played by diskin, so the invalid opcode should return 0. 
i choose an invalid file to test the filevalid opcode.

Le ven. 25 mai 2018 à 11:46, Richard van Bemmelen <[hidden email]> a écrit :
Soundfont files (SF2) cannot be played with the diskin opcodes. You should use the 'sf' family of opcodes for that, e.g. sfload()

Richard

2018-05-25 11:21 GMT+02:00 Rene <[hidden email]>:
Hello list,

I am on linux, csound 6.11

It seems that filevalid opcode only detect if file exit or not, but gives init error is the file exist but is not valid.
 
For example test_filevalid.csd gives

INIT ERROR in instr 1: diskin2: /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file (File contains data in an unknown format.)

and i1 stops!

is it normal?
I wish to use filevalid opcode to prevent the end user to make mistake when browsing waves files.

Regards,
René
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

jpff
How is csound supposed to know what you are going to do with a file?
filevalid check that the file exists and is readable, not what knd if file
it is.  Using diskin on a nown audio file is a plain user error.



On Fri, 25 May 2018, Rene wrote:

> Yes, sf2 cannot be played by diskin, so the invalid opcode should return 0. 
> i choose an invalid file to test the filevalid opcode.
>
> Le ven. 25 mai 2018 à 11:46, Richard van Bemmelen <[hidden email]> a
> écrit :
>       Soundfont files (SF2) cannot be played with the diskin opcodes.
>       You should use the 'sf' family of opcodes for that, e.g. sfload()
> Richard
>
> 2018-05-25 11:21 GMT+02:00 Rene <[hidden email]>:
>       Hello list,
>
> I am on linux, csound 6.11
>
> It seems that filevalid opcode only detect if file exit or not,
> but gives init error is the file exist but is not valid.
>  
> For example test_filevalid.csd gives
>
> INIT ERROR in instr 1: diskin2:
> /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file
> (File contains data in an unknown format.)
>
> and i1 stops!
>
> is it normal?
> I wish to use filevalid opcode to prevent the end user to make
> mistake when browsing waves files.
>
> Regards,
> René
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports
> to https://github.com/csound/csound/issues Discussions of bugs and
> features can be posted here
>
>
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here
>
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

Rene-2
Hi,

Sorry, i get confused because of cs manual:

filevalid is "testing" a sound file and "" returns 1 if the sound file is valid, or 0 if not.""

I was thinking that filevalid return 0 if the file IS NOT a valid sound file.

Best,
René






2018-05-25 17:19 GMT+02:00 jpff <[hidden email]>:
How is csound supposed to know what you are going to do with a file? filevalid check that the file exists and is readable, not what knd if file it is.  Using diskin on a nown audio file is a plain user error.




On Fri, 25 May 2018, Rene wrote:

Yes, sf2 cannot be played by diskin, so the invalid opcode should return 0. 
i choose an invalid file to test the filevalid opcode.

Le ven. 25 mai 2018 à 11:46, Richard van Bemmelen <[hidden email]> a
écrit :
      Soundfont files (SF2) cannot be played with the diskin opcodes.
      You should use the 'sf' family of opcodes for that, e.g. sfload()
Richard

2018-05-25 11:21 GMT+02:00 Rene <[hidden email]>:
      Hello list,

I am on linux, csound 6.11

It seems that filevalid opcode only detect if file exit or not,
but gives init error is the file exist but is not valid.
 
For example test_filevalid.csd gives

INIT ERROR in instr 1: diskin2:
/home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file
(File contains data in an unknown format.)

and i1 stops!

is it normal?
I wish to use filevalid opcode to prevent the end user to make
mistake when browsing waves files.

Regards,
René
Csound mailing list [hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports
to https://github.com/csound/csound/issues Discussions of bugs and
features can be posted here


Csound mailing list [hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features
can be posted here

Csound mailing list [hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

jpff
That could be worded better -- probavly my fault, for which I apologise.

On Fri, 25 May 2018, Rene wrote:

> Hi,
>
> Sorry, i get confused because of cs manual:
>
> filevalid is "testing" a sound file and "" returns 1 if the sound file is
> valid, or 0 if not.""
>
> I was thinking that filevalid return 0 if the file IS NOT a valid sound file.
>
> Best,
> René
>
>
>
>
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

joachim-3
In reply to this post by Rene-2
hi rené -

i think the behaviour of filevalid is useful, as i can use this opcode
not only for audio files, but text files or whatever.

what might work for you: test not (or not only) whether the file is
valid (= exists), but is of the type you expect.  if your file extension
is reliable, you can do:

instr 1

  Sfile = "/home/moi/Works/Samples/sf2/JR_VoicePad.sf2"

  S_extension strsub Sfile, (strrindex(Sfile,"."))
  if strcmp(S_extension,".wav") == 1 then
   aL, aR diskin Sfile
  else
   puts "File is not from expected type!", 1
  endif

endin
schedule 1, 0, 1


of course i wrote a udo for it =)
https://github.com/csudo/csudo/blob/master/strings/pathnames/StrSuf.csd

ciao -
        j



On 25/05/18 19:41, Rene wrote:

> Hi,
>
> Sorry, i get confused because of cs manual:
>
> filevalid is "testing" a sound file and "" returns 1 if the sound file
> is valid, or 0 if not.""
>
> I was thinking that filevalid return 0 if the file IS NOT a valid sound
> file.
>
> Best,
> René
>
>
>
>
>
>
> 2018-05-25 17:19 GMT+02:00 jpff <[hidden email]
> <mailto:[hidden email]>>:
>
>     How is csound supposed to know what you are going to do with a file?
>     filevalid check that the file exists and is readable, not what knd
>     if file it is.  Using diskin on a nown audio file is a plain user error.
>
>
>
>
>     On Fri, 25 May 2018, Rene wrote:
>
>         Yes, sf2 cannot be played by diskin, so the invalid opcode
>         should return 0.
>         i choose an invalid file to test the filevalid opcode.
>
>         Le ven. 25 mai 2018 à 11:46, Richard van Bemmelen
>         <[hidden email] <mailto:[hidden email]>> a
>         écrit :
>               Soundfont files (SF2) cannot be played with the diskin
>         opcodes.
>               You should use the 'sf' family of opcodes for that, e.g.
>         sfload()
>         Richard
>
>         2018-05-25 11:21 GMT+02:00 Rene <[hidden email]
>         <mailto:[hidden email]>>:
>               Hello list,
>
>         I am on linux, csound 6.11
>
>         It seems that filevalid opcode only detect if file exit or not,
>         but gives init error is the file exist but is not valid.
>
>         For example test_filevalid.csd gives
>
>         INIT ERROR in instr 1: diskin2:
>         /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file
>         (File contains data in an unknown format.)
>
>         and i1 stops!
>
>         is it normal?
>         I wish to use filevalid opcode to prevent the end user to make
>         mistake when browsing waves files.
>
>         Regards,
>         René
>         Csound mailing list [hidden email]
>         <mailto:[hidden email]>
>         https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>         <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports
>         to https://github.com/csound/csound/issues
>         <https://github.com/csound/csound/issues> Discussions of bugs and
>         features can be posted here
>
>
>         Csound mailing list [hidden email]
>         <mailto:[hidden email]>
>         https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>         <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
>         reports to
>         https://github.com/csound/csound/issues
>         <https://github.com/csound/csound/issues> Discussions of bugs
>         and features
>         can be posted here
>
>         Csound mailing list [hidden email]
>         <mailto:[hidden email]>
>         https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>         <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
>         reports to
>         https://github.com/csound/csound/issues
>         <https://github.com/csound/csound/issues> Discussions of bugs
>         and features can
>         be posted here
>
>
>     Csound mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>     Send bugs reports to
>            https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>     Discussions of bugs and features can be posted here
>
>
> Csound mailing list [hidden email]
> <mailto:[hidden email]>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

jpff
Of course o GNU/Linux one ought to call file and parse the output......

Any volunteers :-)?

On Sat, 26 May 2018, joachim heintz wrote:

> hi rené -
>
> i think the behaviour of filevalid is useful, as i can use this opcode not
> only for audio files, but text files or whatever.
>
> what might work for you: test not (or not only) whether the file is valid (=
> exists), but is of the type you expect.  if your file extension is reliable,
> ...

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] filevalid opcode question

Rene-2
In reply to this post by joachim-3
Hello Joachim,

I will follow your idea and use your udo :)

Thanks,
René

2018-05-26 13:55 GMT+02:00 joachim heintz <[hidden email]>:
hi rené -

i think the behaviour of filevalid is useful, as i can use this opcode not only for audio files, but text files or whatever.

what might work for you: test not (or not only) whether the file is valid (= exists), but is of the type you expect.  if your file extension is reliable, you can do:

instr 1

 Sfile = "/home/moi/Works/Samples/sf2/JR_VoicePad.sf2"

 S_extension strsub Sfile, (strrindex(Sfile,"."))
 if strcmp(S_extension,".wav") == 1 then
  aL, aR diskin Sfile
 else
  puts "File is not from expected type!", 1
 endif

endin
schedule 1, 0, 1


of course i wrote a udo for it =)
https://github.com/csudo/csudo/blob/master/strings/pathnames/StrSuf.csd

ciao -
        j



On 25/05/18 19:41, Rene wrote:
Hi,

Sorry, i get confused because of cs manual:

filevalid is "testing" a sound file and "" returns 1 if the sound file
is valid, or 0 if not.""

I was thinking that filevalid return 0 if the file IS NOT a valid sound
file.

Best,
René






2018-05-25 17:19 GMT+02:00 jpff <[hidden email]
<mailto:[hidden email]>>:

    How is csound supposed to know what you are going to do with a file?
    filevalid check that the file exists and is readable, not what knd
    if file it is.  Using diskin on a nown audio file is a plain user error.




    On Fri, 25 May 2018, Rene wrote:

        Yes, sf2 cannot be played by diskin, so the invalid opcode
        should return 0.
        i choose an invalid file to test the filevalid opcode.

        Le ven. 25 mai 2018 à 11:46, Richard van Bemmelen
        <[hidden email] <mailto:[hidden email]>> a
        écrit :
              Soundfont files (SF2) cannot be played with the diskin
        opcodes.
              You should use the 'sf' family of opcodes for that, e.g.
        sfload()
        Richard

        2018-05-25 11:21 GMT+02:00 Rene <[hidden email]
        <mailto:[hidden email]>>:
              Hello list,

        I am on linux, csound 6.11

        It seems that filevalid opcode only detect if file exit or not,
        but gives init error is the file exist but is not valid.

        For example test_filevalid.csd gives

        INIT ERROR in instr 1: diskin2:
        /home/moi/Works/Samples/sf2/JR_VoicePad.sf2: failed to open file
        (File contains data in an unknown format.)

        and i1 stops!

        is it normal?
        I wish to use filevalid opcode to prevent the end user to make
        mistake when browsing waves files.

        Regards,
        René
        Csound mailing list [hidden email]
        <mailto:[hidden email]>
        https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
        <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports
        to https://github.com/csound/csound/issues
        <https://github.com/csound/csound/issues> Discussions of bugs and
        features can be posted here


        Csound mailing list [hidden email]
        <mailto:[hidden email]>
        https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
        <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
        reports to
        https://github.com/csound/csound/issues
        <https://github.com/csound/csound/issues> Discussions of bugs
        and features
        can be posted here

        Csound mailing list [hidden email]
        <mailto:[hidden email]>
        https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
        <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
        reports to
        https://github.com/csound/csound/issues
        <https://github.com/csound/csound/issues> Discussions of bugs
        and features can
        be posted here


    Csound mailing list
    [hidden email] <mailto:[hidden email]>
    https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
    <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
    Send bugs reports to
           https://github.com/csound/csound/issues
    <https://github.com/csound/csound/issues>
    Discussions of bugs and features can be posted here


Csound mailing list [hidden email]
<mailto:[hidden email]>
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features
can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here