| Hi Rory,
Yes, I see your point about potential problematic behavior that may
result from loading extremely large files into RAM. Still, it may be
possible to use macros effectively for a streaming from disk solution
such as [1].
-David
[1]
sr = 44100
kr = 441
ksmps = 100
nchnls = 2
#define TEHFILE # "/loops/sup2_abreak16" #
/*--- ---*/
instr 1
ichnls filenchnls $TEHFILE.
if (ichnls <= 1) then
a1 diskin2 $TEHFILE., 1, 0, 1
a2 = a1
elseif (ichnls > 1 && ichnls <= 2) then
a1, a2 diskin2 $TEHFILE., 1, 0, 1
else
/* deal with multichannel; quad, 5.1, ambisonics B-format, etc here */
endif
outs a1, a2
endin
/*--- ---*/
i1 0 10
e
On May 3, 2006, at 9:34 AM, Rory Walsh wrote:
> Yup, that's very straightforward also. I had avoided creating tables
> to make things a little more efficient, for example what if someone
> want to load a one hour piece of music to a table? Not a good idea, or
> maybe I'm wrong. Cheers,
>
> Rory.
>
>
> David Akbari wrote:
>> Hi Rory,
>> I suggested something similar to the blue list some time ago as a
>> sound file mechanism... the idea is this; since long before there
>> were Stype variables in the API, we have had to deal with strings.
>> You guys have already discussed several good ways to deal with this
>> issue, however omitting one crucial and particularly effective
>> mechanism in the Csound language - macro definitions. I often enjoy
>> using a solution like [0] to deal with indexing soundfiles. The bonus
>> over diskin or some other such is to have explicit control over the
>> sample index, similar to how Victor mentioned a constant kndx value
>> to the pvsfread opcode as a technique for "spectral freezing".
>> -David
>> [0]
>>
>>
>> sr = 44100
>> kr = 441
>> ksmps = 100
>> nchnls = 2
>> #define TEHFILE # "/loops/dl_break0.aif" #
>> /*--- ---*/
>> instr 1
>> itabsz filelen $TEHFILE.
>> itmp ftgen 1, 0, (itabsz * sr), 1, $TEHFILE., 0, 4, 0
>> andx phasor (1 / itabsz)
>> andx = andx * (itabsz * sr)
>> a1 table andx, 1
>> a1 = a1 * 32767 ; or 0dBFS
>> outs a1, a1
>> endin
>> /*--- ---*/
>>
>>
>> i1 0 10
>> e
>>
>>
>> On May 3, 2006, at 9:02 AM, Rory Walsh wrote:
>>> I was just wondering if I have gone about this ass ways or not. It
>>> works fine, but I would like to know if there is a better way of
>>> doing it? I want to create an instrument that will play a sound file
>>> that's passed as a string on start-up. I then grab the length of the
>>> sound file and trigger an instrument to play for that length of
>>> time. Basically I don't want to have to be messing around with the
>>> instrument once it's done, it's for a simple sound file player.
>>> Here's the code:
>>>
>>>
>>>
>>> //defualt options
>>> -odac --strset1=D:/MyDocuments/csoundfiles/rory.wav
>>>
>>>
>>> sr = 44100
>>> kr = 4410
>>> ksmps = 10
>>> nchnls = 2
>>>
>>> instr 1
>>> Sname strget 1
>>> strset 10, Sname
>>> gitemp ftgen 1, 0, 0, 1, Sname, 0, 0, 0
>>> ilen filelen "D:/MyDocuments/csoundfiles/rory.wav"
>>> event_i "i", 2, 0, ilen
>>> endin
>>>
>>> instr 2
>>> Sname strget 10
>>> a1, a2 soundin Sname
>>> out a1, a2
>>> endin
>>>
>>>
>>>
>>> i1 0 1
>>>
>>> |