Csound Csound-dev Csound-tekno Search About

Re: [Csnd] file exist opcode?

Date2012-02-13 23:37
From"Art Hunkins"
SubjectRe: [Csnd] file exist opcode?
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 <jh@joachimheintz.de> 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:peimankhosravi@gmail.com>
>     *To:* csound@lists.bath.ac.uk <mailto:csound@lists.bath.ac.uk>
>     *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 <abhunkin@uncg.edu
>     <mailto:abhunkin@uncg.edu>> 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 sympa@lists.bath.ac.uk
>         <mailto:sympa@lists.bath.ac.uk> 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 sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2012-02-14 06:52
Fromjoachim heintz
SubjectRe: [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 
>     *To:* csound@lists.bath.ac.uk 
>     *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      > 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          >
>         >     *To:* csound@lists.bath.ac.uk
>                   >
>         >     *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          
>         >     >> 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 sympa@lists.bath.ac.uk
>         
>         >                  > 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 sympa@lists.bath.ac.uk
>          with body "unsubscribe csound"
> 
> 

Date2012-02-14 09:22
FromTito Latini
SubjectRe: [Csnd] file exist opcode?
AttachmentsNone  

Date2012-02-14 21:45
Fromjoachim heintz
SubjectRe: [Csnd] file exist opcode?
hi tito -
i think this does not work without an error; see below.
or am i missing something?
	joachim



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


i1 0 1
e





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
> 
> 
> 
> 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
> 
> 
> i1 0 1
> e
> 
> 
> 
> 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 sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 

Date2012-02-14 22:23
FromTito Latini
SubjectRe: [Csnd] file exist opcode?
AttachmentsNone