Csound Csound-dev Csound-tekno Search About

[Csnd] Try loading ftable / check existence of file

Date2019-10-31 21:50
From"Jeanette C."
Subject[Csnd] Try loading ftable / check existence of file
Hey hey,
it may be the easiest way to dynamically try and load an ftable using GEN23, 
i.e. from a simple text file. Programmatically I would know the name. It may 
still be that this particular file doesn't exist.

Is there a way, in Csound itself, to check for the existence of an arbitrary 
file or load a function table from a non-existing file without Csound 
crashing. I could always check the ftable size after that statement.

I suppose that I can always check the existence using the system command. Only 
it wouldn't look as pretty and it would either break windows compatibility or 
make for needlessly convoluted code. :)

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There must be another way
Cause I believe in taking chances
But who am I to say - What a girl is to do <3
(Britney Spears)

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

Date2019-10-31 22:12
FromRichard Knight
SubjectRe: [Csnd] Try loading ftable / check existence of file
 Hi
 Maybe the filevalid opcode will do?

 http://www.csounds.com/manual/html/filevalid.html


 Thu, 31 Oct 2019 22:50:10 +0100, Jeanette C. wrote:
> Hey hey,
> it may be the easiest way to dynamically try and load an ftable using
> GEN23, i.e. from a simple text file. Programmatically I would know 
> the
> name. It may still be that this particular file doesn't exist.
>
> Is there a way, in Csound itself, to check for the existence of an
> arbitrary file or load a function table from a non-existing file
> without Csound crashing. I could always check the ftable size after
> that statement.
>
> I suppose that I can always check the existence using the system
> command. Only it wouldn't look as pretty and it would either break
> windows compatibility or make for needlessly convoluted code. :)
>
> Best wishes,
>
> Jeanette
>
> --
>  * Website: http://juliencoder.de - for summer is a state of sound
>  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>  * SoundCloud: https://soundcloud.com/jeanette_c
>  * Twitter: https://twitter.com/jeanette_c_s
>  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>  * GitHub: https://github.com/jeanette-c
>
> There must be another way
> Cause I believe in taking chances
> But who am I to say - What a girl is to do <3
> (Britney Spears)
>
> 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

Date2019-10-31 22:15
FromRichard Knight
SubjectRe: [Csnd] Try loading ftable / check existence of file
 Btw, the manual says it tests existence of a sound file but I am pretty 
 sure I have used it on text/arbitrary  files before.

 On Thu, 31 Oct 2019 22:12:46 +0000, Richard Knight wrote:
> Hi
> Maybe the filevalid opcode will do?
>
> http://www.csounds.com/manual/html/filevalid.html
>
>
> Thu, 31 Oct 2019 22:50:10 +0100, Jeanette C. wrote:
>> Hey hey,
>> it may be the easiest way to dynamically try and load an ftable 
>> using
>> GEN23, i.e. from a simple text file. Programmatically I would know 
>> the
>> name. It may still be that this particular file doesn't exist.
>>
>> Is there a way, in Csound itself, to check for the existence of an
>> arbitrary file or load a function table from a non-existing file
>> without Csound crashing. I could always check the ftable size after
>> that statement.
>>
>> I suppose that I can always check the existence using the system
>> command. Only it wouldn't look as pretty and it would either break
>> windows compatibility or make for needlessly convoluted code. :)
>>
>> Best wishes,
>>
>> Jeanette
>>
>> --
>>  * Website: http://juliencoder.de - for summer is a state of sound
>>  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>>  * SoundCloud: https://soundcloud.com/jeanette_c
>>  * Twitter: https://twitter.com/jeanette_c_s
>>  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>>  * GitHub: https://github.com/jeanette-c
>>
>> There must be another way
>> Cause I believe in taking chances
>> But who am I to say - What a girl is to do <3
>> (Britney Spears)
>>
>> 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

Date2019-10-31 22:44
FromEduardo Moguillansky
SubjectRe: [Csnd] Try loading ftable / check existence of file
I made such an opcode only some days ago:

https://csound-plugins.github.io/csound-plugins/opcodes/file_exists.html

On 31.10.19 22:50, Jeanette C. wrote:
> Hey hey,
> it may be the easiest way to dynamically try and load an ftable using 
> GEN23, i.e. from a simple text file. Programmatically I would know the 
> name. It may still be that this particular file doesn't exist.
>
> Is there a way, in Csound itself, to check for the existence of an 
> arbitrary file or load a function table from a non-existing file 
> without Csound crashing. I could always check the ftable size after 
> that statement.
>
> I suppose that I can always check the existence using the system 
> command. Only it wouldn't look as pretty and it would either break 
> windows compatibility or make for needlessly convoluted code. :)
>
> Best wishes,
>
> Jeanette
>

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

Date2019-10-31 22:45
From"Jeanette C."
SubjectRe: [Csnd] Try loading ftable / check existence of file
Oct 31 2019, Richard Knight has written:

> Btw, the manual says it tests existence of a sound file but I am pretty sure 
> I have used it on text/arbitrary  files before.
That manual entry kept me from trying, pretty silly of me. It does work.
Thanks a lot!

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There must be another way
Cause I believe in taking chances
But who am I to say - What a girl is to do <3
(Britney Spears)

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

Date2019-11-01 06:55
FromBernard Geyer
SubjectRe: [Csnd] Try loading ftable / check existence of file
I use filevalid for text files containing score lines and it works:

iFileExists filevalid S_FileName 
    if (iFileExists > 0) then
read:
      S_Line, kLinNum readf S_FileName
      scoreline S_Line, 1
      ;printf "line %d: %s\n", 1, kLinNum, S_Line
      if kLinNum != -1 then
        kgoto read
      endif
      else
        printf_i "error: no file \"%s\"\n", 1, S_FileName
    endif




--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-11-02 00:37
FromRichard Knight
SubjectRe: [Csnd] Try loading ftable / check existence of file

I have had a look at the source and I think the reason the manual alludes to 'existence of sound files' is because the behaviour is like soundin etc, if the file name given is not a full path then it checks in SFDIR and SSDIR for it. Also an integer can be given and it will look for soundin.n where n is the number, the behaviour is like for soundin's ifilcod on the manual page but that's not specified on the filevalid manual page.
Eduardo's file_exists tests for existence, and filevalid will test if it can be opened (ie permissions exist for that to occur etc). file_exists would more efficient if just testing for an existing file but won't guarantee it can be read.

On Thu, 31 Oct 2019 22:50:10 +0100, Jeanette C. wrote:

Hey hey,
it may be the easiest way to dynamically try and load an ftable using GEN23, 
i.e. from a simple text file. Programmatically I would know the name. It may 
still be that this particular file doesn't exist.

Is there a way, in Csound itself, to check for the existence of an arbitrary 
file or load a function table from a non-existing file without Csound 
crashing. I could always check the ftable size after that statement.

I suppose that I can always check the existence using the system command. Only 
it wouldn't look as pretty and it would either break windows compatibility or 
make for needlessly convoluted code. :)

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There must be another way
Cause I believe in taking chances
But who am I to say - What a girl is to do <3
(Britney Spears)

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
-- 


http://rk.1bpm.net/