Csound Csound-dev Csound-tekno Search About

[Csnd] filevalid opcode question

Date2018-05-25 10:21
FromRene
Subject[Csnd] filevalid opcode question
Attachmentstest_filevalid.csd  
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 Csound@listserv.heanet.ie 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

Date2018-05-25 10:46
FromRichard van Bemmelen
SubjectRe: [Csnd] filevalid opcode question
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 <rene.djack1@gmail.com>:
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 Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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

Date2018-05-25 15:52
FromRene
SubjectRe: [Csnd] filevalid opcode question
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 <zappfinger@gmail.com> 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 <rene.djack1@gmail.com>:
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 Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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

Date2018-05-25 16:19
Fromjpff
SubjectRe: [Csnd] filevalid opcode question
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  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 :
>       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 Csound@listserv.heanet.ie
> 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 Csound@listserv.heanet.ie
> 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 Csound@listserv.heanet.ie
> 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
Csound@listserv.heanet.ie
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

Date2018-05-25 18:41
FromRene
SubjectRe: [Csnd] filevalid opcode question
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 <jpff@codemist.co.uk>:
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 <zappfinger@gmail.com> 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 <rene.djack1@gmail.com>:
      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 Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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

Date2018-05-25 18:44
Fromjpff
SubjectRe: [Csnd] filevalid opcode question
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
Csound@listserv.heanet.ie
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

Date2018-05-26 12:55
Fromjoachim heintz
SubjectRe: [Csnd] filevalid opcode question
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  >:
>
>     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
>         > 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          >:
>               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 Csound@listserv.heanet.ie
>         
>         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 Csound@listserv.heanet.ie
>         
>         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 Csound@listserv.heanet.ie
>         
>         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
>     Csound@listserv.heanet.ie 
>     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 Csound@listserv.heanet.ie
> 
> 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
Csound@listserv.heanet.ie
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

Date2018-05-26 13:01
Fromjpff
SubjectRe: [Csnd] filevalid opcode question
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
Csound@listserv.heanet.ie
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

Date2018-05-26 17:41
FromRene
SubjectRe: [Csnd] filevalid opcode question
Hello Joachim,

I will follow your idea and use your udo :)

Thanks,
René

2018-05-26 13:55 GMT+02:00 joachim heintz <jh@joachimheintz.de>:
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 <jpff@codemist.co.uk
<mailto:jpff@codemist.co.uk>>:

    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
        <zappfinger@gmail.com <mailto:zappfinger@gmail.com>> 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 <rene.djack1@gmail.com
        <mailto:rene.djack1@gmail.com>>:
              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 Csound@listserv.heanet.ie
        <mailto:Csound@listserv.heanet.ie>
        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 Csound@listserv.heanet.ie
        <mailto:Csound@listserv.heanet.ie>
        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 Csound@listserv.heanet.ie
        <mailto:Csound@listserv.heanet.ie>
        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
    Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
    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 Csound@listserv.heanet.ie
<mailto:Csound@listserv.heanet.ie>
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
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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