file exist opcode?

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

file exist opcode?

abhunkin
I feel sure there must be an opcode that returns a value indicating whether
a specified file exists or not. I just cannot find it.

(Otherwise Csound crashes if you ask - via diskin or soundin - for a file
that doesn't exist. I need to avoid this possibility.)

Art Hunkins



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

peiman
maybe you can use the system opcode for this?

P

On 13 February 2012 13:33, Art Hunkins <[hidden email]> wrote:
I feel sure there must be an opcode that returns a value indicating whether a specified file exists or not. I just cannot find it.

(Otherwise Csound crashes if you ask - via diskin or soundin - for a file that doesn't exist. I need to avoid this possibility.)

Art Hunkins


Send bugs reports to the Sourceforge bug tracker
          https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Tito Latini
In reply to this post by abhunkin
Try the `filevalid` opcode

On Mon, Feb 13, 2012 at 08:33:24AM -0500, Art Hunkins wrote:
> I feel sure there must be an opcode that returns a value indicating whether
> a specified file exists or not. I just cannot find it.
>
> (Otherwise Csound crashes if you ask - via diskin or soundin - for a file
> that doesn't exist. I need to avoid this possibility.)
>
> Art Hunkins


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin
Thanks, Tito.

I was using an older Csound and manual which didn't include filevalid. I now
realize I asked this question before and got the same helpful response. A
few chunks of my RAM must have fallen off the edge recently.

Art Hunkins

----- Original Message -----
From: "Tito Latini" <[hidden email]>
To: <[hidden email]>
Sent: Monday, February 13, 2012 8:43 AM
Subject: Re: [Csnd] file exist opcode?


> Try the `filevalid` opcode
>
> On Mon, Feb 13, 2012 at 08:33:24AM -0500, Art Hunkins wrote:
>> I feel sure there must be an opcode that returns a value indicating
>> whether
>> a specified file exists or not. I just cannot find it.
>>
>> (Otherwise Csound crashes if you ask - via diskin or soundin - for a file
>> that doesn't exist. I need to avoid this possibility.)
>>
>> Art Hunkins
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe
> csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin
In reply to this post by peiman
Do you perhaps have a simple, *cross-platform* call to the system opcode that would return whether or not "soundin.1" was present in the current directory?
 
(I'm looking for something applicable back to Csound 5.06; filevalid was only introduced in 5.13. Or is there a simple UDO version of filevalid I might appropriate?)
 
Art Hunkins
----- Original Message -----
Sent: Monday, February 13, 2012 8:36 AM
Subject: Re: [Csnd] file exist opcode?

maybe you can use the system opcode for this?

P

On 13 February 2012 13:33, Art Hunkins <[hidden email]> wrote:
I feel sure there must be an opcode that returns a value indicating whether a specified file exists or not. I just cannot find it.

(Otherwise Csound crashes if you ask - via diskin or soundin - for a file that doesn't exist. I need to avoid this possibility.)

Art Hunkins


Send bugs reports to the Sourceforge bug tracker
          https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

joachim-3
if the python opcodes can be used, this should be possible.
can they?
        joachim

Am 13.02.2012 21:51, schrieb Art Hunkins:

> Do you perhaps have a simple, *cross-platform* call to the system opcode
> that would return whether or not "soundin.1" was present in the current
> directory?
>  
> (I'm looking for something applicable back to Csound 5.06; filevalid was
> only introduced in 5.13. Or is there a simple UDO version of filevalid I
> might appropriate?)
>  
> Art Hunkins
>
>     ----- Original Message -----
>     *From:* peiman khosravi <mailto:[hidden email]>
>     *To:* [hidden email] <mailto:[hidden email]>
>     *Sent:* Monday, February 13, 2012 8:36 AM
>     *Subject:* Re: [Csnd] file exist opcode?
>
>     maybe you can use the system opcode for this?
>
>     P
>
>     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>         I feel sure there must be an opcode that returns a value
>         indicating whether a specified file exists or not. I just cannot
>         find it.
>
>         (Otherwise Csound crashes if you ask - via diskin or soundin -
>         for a file that doesn't exist. I need to avoid this possibility.)
>
>         Art Hunkins
>
>
>         Send bugs reports to the Sourceforge bug tracker
>                  
>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>         Discussions of bugs and features can be posted here
>         To unsubscribe, send email [hidden email]
>         <mailto:[hidden email]> with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Andres Cabrera
Hi,

Yes, I think using os.path.exists should work on all platforms.

Cheers,
Andrés

On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz <[hidden email]> wrote:
if the python opcodes can be used, this should be possible.
can they?
       joachim

Am 13.02.2012 21:51, schrieb Art Hunkins:
> Do you perhaps have a simple, *cross-platform* call to the system opcode
> that would return whether or not "soundin.1" was present in the current
> directory?
>
> (I'm looking for something applicable back to Csound 5.06; filevalid was
> only introduced in 5.13. Or is there a simple UDO version of filevalid I
> might appropriate?)
>
> Art Hunkins
>
>     ----- Original Message -----
>     *From:* peiman khosravi <mailto:[hidden email]>
>     *To:* [hidden email] <mailto:[hidden email]>
>     *Sent:* Monday, February 13, 2012 8:36 AM
>     *Subject:* Re: [Csnd] file exist opcode?
>
>     maybe you can use the system opcode for this?
>
>     P
>
>     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>         I feel sure there must be an opcode that returns a value
>         indicating whether a specified file exists or not. I just cannot
>         find it.
>
>         (Otherwise Csound crashes if you ask - via diskin or soundin -
>         for a file that doesn't exist. I need to avoid this possibility.)
>
>         Art Hunkins
>
>
>         Send bugs reports to the Sourceforge bug tracker
>
>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>         Discussions of bugs and features can be posted here
>         To unsubscribe, send email [hidden email]
>         <mailto:[hidden email]> with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin

Thanks to all for the suggestions.
 
Unfortunately, I cannot count on python always being available.
 
Can anyone suggest a simple solution using the system opcode - one that perhaps parallels "os.path.exists"?
 
Art Hunkins
----- Original Message -----
Sent: Monday, February 13, 2012 4:42 PM
Subject: Re: [Csnd] file exist opcode?

Hi,

Yes, I think using os.path.exists should work on all platforms.

Cheers,
Andrés

On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz <[hidden email]> wrote:
if the python opcodes can be used, this should be possible.
can they?
       joachim

Am 13.02.2012 21:51, schrieb Art Hunkins:
> Do you perhaps have a simple, *cross-platform* call to the system opcode

> that would return whether or not "soundin.1" was present in the current
> directory?
>
> (I'm looking for something applicable back to Csound 5.06; filevalid was
> only introduced in 5.13. Or is there a simple UDO version of filevalid I
> might appropriate?)
>
> Art Hunkins
>
>     ----- Original Message -----
>     *From:* peiman khosravi <mailto:[hidden email]>
>     *To:* [hidden email] <mailto:[hidden email]>
>     *Sent:* Monday, February 13, 2012 8:36 AM
>     *Subject:* Re: [Csnd] file exist opcode?
>
>     maybe you can use the system opcode for this?
>
>     P
>
>     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>     <mailto:[hidden email]>> wrote:

>
>         I feel sure there must be an opcode that returns a value
>         indicating whether a specified file exists or not. I just cannot
>         find it.
>
>         (Otherwise Csound crashes if you ask - via diskin or soundin -
>         for a file that doesn't exist. I need to avoid this possibility.)
>
>         Art Hunkins
>
>
>         Send bugs reports to the Sourceforge bug tracker
>
>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>         Discussions of bugs and features can be posted here
>         To unsubscribe, send email [hidden email]
>         <mailto:[hidden email]> with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

joachim-3
hi art -
this works for linux (ires=0: file noes not exist), and should for osx.
but on windows?
perhaps it helps anyways -
        joachim

instr 1
ires system_i 1, "if [ -f test.csd ] ; then 1 ; fi"
print ires
endin

Am 14.02.2012 00:37, schrieb Art Hunkins:

> Thanks to all for the suggestions.
>  
> Unfortunately, I cannot count on python always being available.
>  
> Can anyone suggest a simple solution using the system opcode - one that
> perhaps parallels "os.path.exists"?
>  
> Art Hunkins
>
>     ----- Original Message -----
>     *From:* Andres Cabrera <mailto:[hidden email]>
>     *To:* [hidden email] <mailto:[hidden email]>
>     *Sent:* Monday, February 13, 2012 4:42 PM
>     *Subject:* Re: [Csnd] file exist opcode?
>
>     Hi,
>
>     Yes, I think using os.path.exists should work on all platforms.
>
>     Cheers,
>     Andrés
>
>     On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>         if the python opcodes can be used, this should be possible.
>         can they?
>                joachim
>
>         Am 13.02.2012 21:51, schrieb Art Hunkins:
>         > Do you perhaps have a simple, *cross-platform* call to the
>         system opcode
>         > that would return whether or not "soundin.1" was present in
>         the current
>         > directory?
>         >
>         > (I'm looking for something applicable back to Csound 5.06;
>         filevalid was
>         > only introduced in 5.13. Or is there a simple UDO version of
>         filevalid I
>         > might appropriate?)
>         >
>         > Art Hunkins
>         >
>         >     ----- Original Message -----
>         >     *From:* peiman khosravi <mailto:[hidden email]
>         <mailto:[hidden email]>>
>         >     *To:* [hidden email]
>         <mailto:[hidden email]> <mailto:[hidden email]
>         <mailto:[hidden email]>>
>         >     *Sent:* Monday, February 13, 2012 8:36 AM
>         >     *Subject:* Re: [Csnd] file exist opcode?
>         >
>         >     maybe you can use the system opcode for this?
>         >
>         >     P
>         >
>         >     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>         <mailto:[hidden email]>
>         >     <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>         >
>         >         I feel sure there must be an opcode that returns a value
>         >         indicating whether a specified file exists or not. I
>         just cannot
>         >         find it.
>         >
>         >         (Otherwise Csound crashes if you ask - via diskin or
>         soundin -
>         >         for a file that doesn't exist. I need to avoid this
>         possibility.)
>         >
>         >         Art Hunkins
>         >
>         >
>         >         Send bugs reports to the Sourceforge bug tracker
>         >
>         >        
>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>         <https://sourceforge.net/__tracker/?group_id=81968&atid=__564599>
>         >        
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>>
>         >         Discussions of bugs and features can be posted here
>         >         To unsubscribe, send email [hidden email]
>         <mailto:[hidden email]>
>         >         <mailto:[hidden email]
>         <mailto:[hidden email]>> with body "unsubscribe csound"
>         >
>         >
>
>
>         Send bugs reports to the Sourceforge bug tracker
>                  
>          https://sourceforge.net/tracker/?group_id=81968&atid=564599
>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>         Discussions of bugs and features can be posted here
>         To unsubscribe, send email [hidden email]
>         <mailto:[hidden email]> with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Tito Latini
In reply to this post by abhunkin
> Unfortunately, I cannot count on python always being available.
>
> Can anyone suggest a simple solution using the system opcode - one that perhaps parallels "os.path.exists"?

The hidden filevalid

<CsoundSynthesizer>
<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 1

;; filevalid for csound < 5.13 (tested with 5.07)
opcode filevalid, i, S
  Sfile xin
  ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
  xout ires - 2011
endop

instr 1
Sfile = "dindondan.wav"
ires filevalid Sfile
if (ires != 1) igoto end
aout soundin Sfile
out aout
end:
if (ires != 1) then
  turnoff
endif
endin
</CsInstruments>
<CsScore>
i1 0 1
e
</CsScore>
</CsoundSynthesizer>

tito


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin
In reply to this post by joachim-3
Joachim,

I cannot tell if your suggestion will work on Windows or not.

Csound 5.06, which I happen to need to use, does include the system_i
opcode. However, on Windows, ires *always* returns a value of 1.

This happens:
1) whether the file exists or not;
2) regardless of what the return value options are (the value[s?] following
"then").

So, is this a platform-related problem?

If so, is perhaps there another way of formatting the filename that would
work for Windows?

Art Hunkins

----- Original Message -----
From: "joachim heintz" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, February 14, 2012 1:52 AM
Subject: Re: [Csnd] file exist opcode?


> hi art -
> this works for linux (ires=0: file noes not exist), and should for osx.
> but on windows?
> perhaps it helps anyways -
> joachim
>
> instr 1
> ires system_i 1, "if [ -f test.csd ] ; then 1 ; fi"
> print ires
> endin
>
> Am 14.02.2012 00:37, schrieb Art Hunkins:
>> Thanks to all for the suggestions.
>>
>> Unfortunately, I cannot count on python always being available.
>>
>> Can anyone suggest a simple solution using the system opcode - one that
>> perhaps parallels "os.path.exists"?
>>
>> Art Hunkins
>>
>>     ----- Original Message -----
>>     *From:* Andres Cabrera <mailto:[hidden email]>
>>     *To:* [hidden email] <mailto:[hidden email]>
>>     *Sent:* Monday, February 13, 2012 4:42 PM
>>     *Subject:* Re: [Csnd] file exist opcode?
>>
>>     Hi,
>>
>>     Yes, I think using os.path.exists should work on all platforms.
>>
>>     Cheers,
>>     Andrés
>>
>>     On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz <[hidden email]
>>     <mailto:[hidden email]>> wrote:
>>
>>         if the python opcodes can be used, this should be possible.
>>         can they?
>>                joachim
>>
>>         Am 13.02.2012 21:51, schrieb Art Hunkins:
>>         > Do you perhaps have a simple, *cross-platform* call to the
>>         system opcode
>>         > that would return whether or not "soundin.1" was present in
>>         the current
>>         > directory?
>>         >
>>         > (I'm looking for something applicable back to Csound 5.06;
>>         filevalid was
>>         > only introduced in 5.13. Or is there a simple UDO version of
>>         filevalid I
>>         > might appropriate?)
>>         >
>>         > Art Hunkins
>>         >
>>         >     ----- Original Message -----
>>         >     *From:* peiman khosravi <mailto:[hidden email]
>>         <mailto:[hidden email]>>
>>         >     *To:* [hidden email]
>>         <mailto:[hidden email]> <mailto:[hidden email]
>>         <mailto:[hidden email]>>
>>         >     *Sent:* Monday, February 13, 2012 8:36 AM
>>         >     *Subject:* Re: [Csnd] file exist opcode?
>>         >
>>         >     maybe you can use the system opcode for this?
>>         >
>>         >     P
>>         >
>>         >     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>>         <mailto:[hidden email]>
>>         >     <mailto:[hidden email] <mailto:[hidden email]>>>
>> wrote:
>>         >
>>         >         I feel sure there must be an opcode that returns a
>> value
>>         >         indicating whether a specified file exists or not. I
>>         just cannot
>>         >         find it.
>>         >
>>         >         (Otherwise Csound crashes if you ask - via diskin or
>>         soundin -
>>         >         for a file that doesn't exist. I need to avoid this
>>         possibility.)
>>         >
>>         >         Art Hunkins
>>         >
>>         >
>>         >         Send bugs reports to the Sourceforge bug tracker
>>         >
>>         >
>>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>>         <https://sourceforge.net/__tracker/?group_id=81968&atid=__564599>
>>         >
>>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>>
>>         >         Discussions of bugs and features can be posted here
>>         >         To unsubscribe, send email [hidden email]
>>         <mailto:[hidden email]>
>>         >         <mailto:[hidden email]
>>         <mailto:[hidden email]>> with body "unsubscribe csound"
>>         >
>>         >
>>
>>
>>         Send bugs reports to the Sourceforge bug tracker
>>
>>          https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>         <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>>         Discussions of bugs and features can be posted here
>>         To unsubscribe, send email [hidden email]
>>         <mailto:[hidden email]> with body "unsubscribe csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe
> csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Alan Fitch
On 14/02/2012 16:35, Art Hunkins wrote:

> Joachim,
>
> I cannot tell if your suggestion will work on Windows or not.
>
> Csound 5.06, which I happen to need to use, does include the system_i
> opcode. However, on Windows, ires *always* returns a value of 1.
>
> This happens:
> 1) whether the file exists or not;
> 2) regardless of what the return value options are (the value[s?]
> following "then").
>
> So, is this a platform-related problem?
>
> If so, is perhaps there another way of formatting the filename that
> would work for Windows?
>

Hi Art,
   the code in Joachim's example looks like bash script, which won't
work on Windows.

However this might work...

ires system_i 1, "if not exist test.csd exit 0 else exit 1"

I think the command in the "" needs to be made up of windows batch
commands. "if exist" tests for a file's existence.

Good luck...

Alan

P.S. Of course this code is Windows specific

> Art Hunkins
>
> ----- Original Message ----- From: "joachim heintz" <[hidden email]>
> To: <[hidden email]>
> Sent: Tuesday, February 14, 2012 1:52 AM
> Subject: Re: [Csnd] file exist opcode?
>
>
>> hi art -
>> this works for linux (ires=0: file noes not exist), and should for osx.
>> but on windows?
>> perhaps it helps anyways -
>> joachim
>>
>> instr 1
>> ires system_i 1, "if [ -f test.csd ] ; then 1 ; fi"
>> print ires
>> endin
>>
>> Am 14.02.2012 00:37, schrieb Art Hunkins:
>>> Thanks to all for the suggestions.
>>>
>>> Unfortunately, I cannot count on python always being available.
>>>
>>> Can anyone suggest a simple solution using the system opcode - one that
>>> perhaps parallels "os.path.exists"?
>>>
>>> Art Hunkins
>>>
>>>     ----- Original Message -----
>>>     *From:* Andres Cabrera <mailto:[hidden email]>
>>>     *To:* [hidden email] <mailto:[hidden email]>
>>>     *Sent:* Monday, February 13, 2012 4:42 PM
>>>     *Subject:* Re: [Csnd] file exist opcode?
>>>
>>>     Hi,
>>>
>>>     Yes, I think using os.path.exists should work on all platforms.
>>>
>>>     Cheers,
>>>     Andrés
>>>
>>>     On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz
>>> <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>>         if the python opcodes can be used, this should be possible.
>>>         can they?
>>>                joachim
>>>
>>>         Am 13.02.2012 21:51, schrieb Art Hunkins:
>>> > Do you perhaps have a simple, *cross-platform* call to the
>>>         system opcode
>>> > that would return whether or not "soundin.1" was present in
>>>         the current
>>> > directory?
>>> >
>>> > (I'm looking for something applicable back to Csound 5.06;
>>>         filevalid was
>>> > only introduced in 5.13. Or is there a simple UDO version of
>>>         filevalid I
>>> > might appropriate?)
>>> >
>>> > Art Hunkins
>>> >
>>> >     ----- Original Message -----
>>> >     *From:* peiman khosravi <mailto:[hidden email]
>>> <mailto:[hidden email]>>
>>> >     *To:* [hidden email]
>>> <mailto:[hidden email]> <mailto:[hidden email]
>>> <mailto:[hidden email]>>
>>> >     *Sent:* Monday, February 13, 2012 8:36 AM
>>> >     *Subject:* Re: [Csnd] file exist opcode?
>>> >
>>> >     maybe you can use the system opcode for this?
>>> >
>>> >     P
>>> >
>>> >     On 13 February 2012 13:33, Art Hunkins <[hidden email]
>>> <mailto:[hidden email]>
>>> > <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>>> >
>>> >         I feel sure there must be an opcode that returns a value
>>> >         indicating whether a specified file exists or not. I
>>>         just cannot
>>> >         find it.
>>> >
>>> >         (Otherwise Csound crashes if you ask - via diskin or
>>>         soundin -
>>> >         for a file that doesn't exist. I need to avoid this
>>>         possibility.)
>>> >
>>> >         Art Hunkins
>>> >
>>> >
>>> >         Send bugs reports to the Sourceforge bug tracker
>>> >
>>> >
>>>         https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>>> <https://sourceforge.net/__tracker/?group_id=81968&atid=__564599>
>>> >
>>> <https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> <https://sourceforge.net/tracker/?group_id=81968&atid=564599>>
>>> >         Discussions of bugs and features can be posted here
>>> >         To unsubscribe, send email [hidden email]
>>> <mailto:[hidden email]>
>>> > <mailto:[hidden email]
>>> <mailto:[hidden email]>> with body "unsubscribe csound"
>>> >
>>> >
>>>
>>>
>>>         Send bugs reports to the Sourceforge bug tracker
>>>
>>>          https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
>>>         Discussions of bugs and features can be posted here
>>>         To unsubscribe, send email [hidden email]
>>> <mailto:[hidden email]> with body "unsubscribe csound"
>>>
>>>
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email [hidden email] with body
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body
> "unsubscribe csound"
>


--
Alan Fitch



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

joachim-3
In reply to this post by Tito Latini
hi tito -
i think this does not work without an error; see below.
or am i missing something?
        joachim

<CsoundSynthesizer>
<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 1

;; filevalid for csound < 5.13 (tested with 5.07)
opcode filevalid2, i, S
  Sfile xin
  ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
  xout ires - 2011
endop

instr 1
Sfile = "dindondan.wav"
ires filevalid2 Sfile
if (ires != 1) igoto end
aout soundin Sfile
out aout
end:
if (ires != 1) then
  turnoff
endif
endin
</CsInstruments>
<CsScore>
i1 0 1
e
</CsScore>
</CsoundSynthesizer>



orch now loaded
audio buffered in 256 sample-frame blocks
ALSA input: total buffer size: 1024, period size: 256
reading 512-byte blks of shorts from adc (RAW)
ALSA output: total buffer size: 1024, period size: 256
writing 256 sample blks of 64-bit floats to dac
SECTION 1:
new alloc for instr 1:
ftable 2012:
soundin cannot open dindondan.wav
ftable 2012: Failed to open file
f2012     0.00     2.00     1.00  "dindondan.wav" ...
INIT ERROR in instr 1 (opcode filevalid2): ftgen error
ires ftgen 2012 0 2 1 Sfile 0 0 0
          B  0.000 - note deleted.  i1 had 1 init errors
Score finished in csoundPerformKsmps().
inactive allocs returned to freespace
end of score.   overall amps:      0.0
           overall samples out of range:        0
1 errors in performance
Elapsed time at end of performance: real: 0.014s, CPU: 0.010s
0 256 sample blks of 64-bit floats written to dac


Am 14.02.2012 10:22, schrieb Tito Latini:

>> Unfortunately, I cannot count on python always being available.
>>
>> Can anyone suggest a simple solution using the system opcode - one that perhaps parallels "os.path.exists"?
>
> The hidden filevalid
>
> <CsoundSynthesizer>
> <CsInstruments>
> sr     = 44100
> ksmps  = 64
> nchnls = 1
>
> ;; filevalid for csound < 5.13 (tested with 5.07)
> opcode filevalid, i, S
>   Sfile xin
>   ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
>   xout ires - 2011
> endop
>
> instr 1
> Sfile = "dindondan.wav"
> ires filevalid Sfile
> if (ires != 1) igoto end
> aout soundin Sfile
> out aout
> end:
> if (ires != 1) then
>   turnoff
> endif
> endin
> </CsInstruments>
> <CsScore>
> i1 0 1
> e
> </CsScore>
> </CsoundSynthesizer>
>
> tito
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin
Yes, this is the identical result I get on Windows XP, with Csound 5.06.

Also, if possible, I need a version that allows a soundin.N (integer) input
to the UDO.

Perhaps once we get the main issue sorted, this latter request will be
easily solved.

Art Hunkins

----- Original Message -----
From: "joachim heintz" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, February 14, 2012 4:45 PM
Subject: Re: [Csnd] file exist opcode?


> hi tito -
> i think this does not work without an error; see below.
> or am i missing something?
> joachim
>
> <CsoundSynthesizer>
> <CsInstruments>
> sr     = 44100
> ksmps  = 64
> nchnls = 1
>
> ;; filevalid for csound < 5.13 (tested with 5.07)
> opcode filevalid2, i, S
>  Sfile xin
>  ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
>  xout ires - 2011
> endop
>
> instr 1
> Sfile = "dindondan.wav"
> ires filevalid2 Sfile
> if (ires != 1) igoto end
> aout soundin Sfile
> out aout
> end:
> if (ires != 1) then
>  turnoff
> endif
> endin
> </CsInstruments>
> <CsScore>
> i1 0 1
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> orch now loaded
> audio buffered in 256 sample-frame blocks
> ALSA input: total buffer size: 1024, period size: 256
> reading 512-byte blks of shorts from adc (RAW)
> ALSA output: total buffer size: 1024, period size: 256
> writing 256 sample blks of 64-bit floats to dac
> SECTION 1:
> new alloc for instr 1:
> ftable 2012:
> soundin cannot open dindondan.wav
> ftable 2012: Failed to open file
> f2012     0.00     2.00     1.00  "dindondan.wav" ...
> INIT ERROR in instr 1 (opcode filevalid2): ftgen error
> ires ftgen 2012 0 2 1 Sfile 0 0 0
>   B  0.000 - note deleted.  i1 had 1 init errors
> Score finished in csoundPerformKsmps().
> inactive allocs returned to freespace
> end of score.    overall amps:      0.0
>    overall samples out of range:        0
> 1 errors in performance
> Elapsed time at end of performance: real: 0.014s, CPU: 0.010s
> 0 256 sample blks of 64-bit floats written to dac
>
>
> Am 14.02.2012 10:22, schrieb Tito Latini:
>>> Unfortunately, I cannot count on python always being available.
>>>
>>> Can anyone suggest a simple solution using the system opcode - one that
>>> perhaps parallels "os.path.exists"?
>>
>> The hidden filevalid
>>
>> <CsoundSynthesizer>
>> <CsInstruments>
>> sr     = 44100
>> ksmps  = 64
>> nchnls = 1
>>
>> ;; filevalid for csound < 5.13 (tested with 5.07)
>> opcode filevalid, i, S
>>   Sfile xin
>>   ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
>>   xout ires - 2011
>> endop
>>
>> instr 1
>> Sfile = "dindondan.wav"
>> ires filevalid Sfile
>> if (ires != 1) igoto end
>> aout soundin Sfile
>> out aout
>> end:
>> if (ires != 1) then
>>   turnoff
>> endif
>> endin
>> </CsInstruments>
>> <CsScore>
>> i1 0 1
>> e
>> </CsScore>
>> </CsoundSynthesizer>
>>
>> tito
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email [hidden email] with body "unsubscribe
>> csound"
>>
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe
> csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Tito Latini
In reply to this post by joachim-3
I have written this solution only to avoid a crash,
I believed that it was the problem

On Tue, Feb 14, 2012 at 10:45:33PM +0100, joachim heintz wrote:

> hi tito -
> i think this does not work without an error; see below.
> or am i missing something?
> joachim
>
> <CsoundSynthesizer>
> <CsInstruments>
> sr     = 44100
> ksmps  = 64
> nchnls = 1
>
> ;; filevalid for csound < 5.13 (tested with 5.07)
> opcode filevalid2, i, S
>   Sfile xin
>   ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
>   xout ires - 2011
> endop
>
> instr 1
> Sfile = "dindondan.wav"
> ires filevalid2 Sfile
> if (ires != 1) igoto end
> aout soundin Sfile
> out aout
> end:
> if (ires != 1) then
>   turnoff
> endif
> endin
> </CsInstruments>
> <CsScore>
> i1 0 1
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> orch now loaded
> audio buffered in 256 sample-frame blocks
> ALSA input: total buffer size: 1024, period size: 256
> reading 512-byte blks of shorts from adc (RAW)
> ALSA output: total buffer size: 1024, period size: 256
> writing 256 sample blks of 64-bit floats to dac
> SECTION 1:
> new alloc for instr 1:
> ftable 2012:
> soundin cannot open dindondan.wav
> ftable 2012: Failed to open file
> f2012     0.00     2.00     1.00  "dindondan.wav" ...
> INIT ERROR in instr 1 (opcode filevalid2): ftgen error
> ires ftgen 2012 0 2 1 Sfile 0 0 0
>  B  0.000 - note deleted.  i1 had 1 init errors
> Score finished in csoundPerformKsmps().
> inactive allocs returned to freespace
> end of score.   overall amps:      0.0
>   overall samples out of range:        0
> 1 errors in performance
> Elapsed time at end of performance: real: 0.014s, CPU: 0.010s
> 0 256 sample blks of 64-bit floats written to dac
>
>
> Am 14.02.2012 10:22, schrieb Tito Latini:
> >> Unfortunately, I cannot count on python always being available.
> >>
> >> Can anyone suggest a simple solution using the system opcode - one that perhaps parallels "os.path.exists"?
> >
> > The hidden filevalid
> >
> > <CsoundSynthesizer>
> > <CsInstruments>
> > sr     = 44100
> > ksmps  = 64
> > nchnls = 1
> >
> > ;; filevalid for csound < 5.13 (tested with 5.07)
> > opcode filevalid, i, S
> >   Sfile xin
> >   ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
> >   xout ires - 2011
> > endop
> >
> > instr 1
> > Sfile = "dindondan.wav"
> > ires filevalid Sfile
> > if (ires != 1) igoto end
> > aout soundin Sfile
> > out aout
> > end:
> > if (ires != 1) then
> >   turnoff
> > endif
> > endin
> > </CsInstruments>
> > <CsScore>
> > i1 0 1
> > e
> > </CsScore>
> > </CsoundSynthesizer>
> >
> > tito
> >
> >
> > Send bugs reports to the Sourceforge bug tracker
> >             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> > Discussions of bugs and features can be posted here
> > To unsubscribe, send email [hidden email] with body "unsubscribe csound"
> >
> >
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Tito Latini
In reply to this post by abhunkin
> Yes, this is the identical result I get on Windows XP, with Csound 5.06.
>
> Also, if possible, I need a version that allows a soundin.N (integer) input
> to the UDO.
>
> Perhaps once we get the main issue sorted, this latter request will be
> easily solved.
>
> Art Hunkins

The error with ftgen avoids the crash with 5.06.
Updated example:

<CsoundSynthesizer>
<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 2

;; filevalid for csound < 5.13 (tested with 5.07)
opcode filevalid_S, i, S
  Sfile xin
  ires ftgen 2012, 0, 2, 1, Sfile, 0, 0, 0
  xout ires - 2011
endop

opcode filevalid_i, i, i
  ifilcod xin
  ires ftgen 2012, 0, 2, 1, ifilcod, 0, 0, 0
  xout ires - 2011
endop

instr 1
Sfile = "dindondan.wav"
ires filevalid_S Sfile
if (ires != 1) igoto end
al soundin Sfile

ifile = 1
ires filevalid_i ifile
if (ires != 1) igoto end
ar soundin ifile

outs al, ar
end:
if (ires != 1) then
  turnoff
endif
endin
</CsInstruments>
<CsScore>
i1 0 1
e
</CsScore>
</CsoundSynthesizer>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

Tito Latini
In reply to this post by abhunkin
Here is a portable (I think) `filevalid_*' that uses
the `system_i' opcode (tested with 5.07)

<CsoundSynthesizer>
<CsInstruments>

gios_check = 0

;; ires filevalid_S filename
opcode filevalid_S, i, S
  Sfile xin
  if (gios_check == 1) igoto cont
  ires system_i 1, "exit nonzero"
  if (ires != 0) then
    ;; unix (like)
    gSfmt = "test ! -f '%s'"
  else
    ;; windows/dos
    gSfmt = "if exist %s exit 1"
  endif
  gios_check = 1
cont:
  Scmd sprintf gSfmt, Sfile
  ires system_i 1, Scmd
  xout (ires != 0 ? 1 : 0)
endop

;; ires filevalid_i ifilcod
opcode filevalid_i, i, i
  ifilcod xin
  Sfile sprintf "soundin.%d", ifilcod
  ires filevalid_S Sfile
  xout ires
endop

instr 1   ; test
ires filevalid_S "somefile.wav"
print ires
ires filevalid_i 1     ; check soundin.1
print ires
endin

</CsInstruments>
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>

tito


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: file exist opcode?

abhunkin
Tito,

Thanks for all this good work.

These suggestions have become way too complex for my simple situation.

The current filevalid opcode, I presume, is also as complicated as this. Is
this so?

I gather that the problem here is basically dealing with varied operating
systems?

Art Hunkins

----- Original Message -----
From: "Tito Latini" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2012 5:58 AM
Subject: Re: [Csnd] file exist opcode?


> Here is a portable (I think) `filevalid_*' that uses
> the `system_i' opcode (tested with 5.07)
>
> <CsoundSynthesizer>
> <CsInstruments>
>
> gios_check = 0
>
> ;; ires filevalid_S filename
> opcode filevalid_S, i, S
>  Sfile xin
>  if (gios_check == 1) igoto cont
>  ires system_i 1, "exit nonzero"
>  if (ires != 0) then
>    ;; unix (like)
>    gSfmt = "test ! -f '%s'"
>  else
>    ;; windows/dos
>    gSfmt = "if exist %s exit 1"
>  endif
>  gios_check = 1
> cont:
>  Scmd sprintf gSfmt, Sfile
>  ires system_i 1, Scmd
>  xout (ires != 0 ? 1 : 0)
> endop
>
> ;; ires filevalid_i ifilcod
> opcode filevalid_i, i, i
>  ifilcod xin
>  Sfile sprintf "soundin.%d", ifilcod
>  ires filevalid_S Sfile
>  xout ires
> endop
>
> instr 1   ; test
> ires filevalid_S "somefile.wav"
> print ires
> ires filevalid_i 1     ; check soundin.1
> print ires
> endin
>
> </CsInstruments>
> <CsScore>
> i1 0 1
> </CsScore>
> </CsoundSynthesizer>
>
> tito
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email [hidden email] with body "unsubscribe
> csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Loading...