Csound Csound-dev Csound-tekno Search About

looping in loscil?

Date2006-04-21 14:44
FromBen Collver
Subjectlooping in loscil?
AttachmentsNone  

Date2006-04-21 16:06
FromPrent Rodgers
SubjectRe: looping in loscil?
Ben,

oscilloscope looping doesn't always do what you think it should. I use 
it extensively in my Csound work and have learned to avoid the quirks. 
If you want to use looping, the format has to be .aif, not .wav. I use a 
program called Awave Studio to correct the loop points, which are 
notoriously tough to get right. http://www.fmjsoft.com/awavestudio.html 
has it for sale.

For each sample I use, I need to keep track of if it has a loop or not, 
and if it is stereo or mono. I store that info in variables iwavchan and 
iloop in this fragment. kcps2 is the frequency adjusted to the nearest 
cent, ifno is the sample function table, ibascps is the base frequency 
of the sample as recorded.


  ; calculate the frequency, the right sample to use, and other factors 
first
  ; Four choices: Mono looping, stereo looping, mono no-loop, stereo 
no-loop
  if iwavchan = 4 goto akaimono
  if iloop = 0 goto noloops
  ; Stereo with loop
  a3,a4 loscil 1, kcps2, ifno, ibascps; stereo sample with looping
  goto skipstereo
  noloops:
  ; Stereo without looping
  a3,a4 loscil 1, kcps2, ifno, ibascps,0,1,2 ; stereo sample without 
looping - note that 1,2 is bogus workaround
  goto skipstereo
  akaimono:
  if iloop = 0 goto noloopm
  ; Mono with looping
  a3 loscil 1, kcps2, ifno, ibascps ; mono sampling with loop
  a4 = a3
  goto skipstereo
  noloopm:
  ; Mono without looping
  a3 loscil 1, kcps2, ifno, ibascps,0,1,2 ; mono AIFF sample without loop
  a4 = a3

  skipstereo:
   ; apply the envelope

Ben Collver wrote:
> I could not get looping to work using loscil.
> 
> The manual states "If sampling reaches the sustain loop endpoint and
> looping is in effect, the point of sampling will be modified and loscil
> will continue reading from within that loop segment."
> 
> How do I set it so that looping is in effect?  Would someone show me an
> example orchestra and score?
> 
> Thank you,
> 
> Ben

-- 
Music that's "Fake but Accurate"!
Web page: http://prodgers13.home.comcast.net
Podcast: http://podcast1024.libsyn.com
Another Podcast: http://BumperMusic.blogspot.com
Music: http://www.soundclick.com/PrentRodgers

Date2006-04-21 16:13
FromPrent Rodgers
SubjectRe: looping in loscil?
The first word in my note should have been "loscil" looping. Spell 
checker "fixed" it to "oscilloscope" for me. Thank you.

Prent Rodgers wrote:
> Ben,
> 
> oscilloscope looping doesn't always do what you think it should. I use 
> it extensively in my Csound work and have learned to avoid the quirks. 
> If you want to use looping, the format has to be .aif, not .wav. I use a 
> program called Awave Studio to correct the loop points, which are 
> notoriously tough to get right. http://www.fmjsoft.com/awavestudio.html 
> has it for sale.
> 
> For each sample I use, I need to keep track of if it has a loop or not, 
> and if it is stereo or mono. I store that info in variables iwavchan and 
> iloop in this fragment. kcps2 is the frequency adjusted to the nearest 
> cent, ifno is the sample function table, ibascps is the base frequency 
> of the sample as recorded.
> 
> 
>  ; calculate the frequency, the right sample to use, and other factors 
> first
>  ; Four choices: Mono looping, stereo looping, mono no-loop, stereo no-loop
>  if iwavchan = 4 goto akaimono
>  if iloop = 0 goto noloops
>  ; Stereo with loop
>  a3,a4 loscil 1, kcps2, ifno, ibascps; stereo sample with looping
>  goto skipstereo
>  noloops:
>  ; Stereo without looping
>  a3,a4 loscil 1, kcps2, ifno, ibascps,0,1,2 ; stereo sample without 
> looping - note that 1,2 is bogus workaround
>  goto skipstereo
>  akaimono:
>  if iloop = 0 goto noloopm
>  ; Mono with looping
>  a3 loscil 1, kcps2, ifno, ibascps ; mono sampling with loop
>  a4 = a3
>  goto skipstereo
>  noloopm:
>  ; Mono without looping
>  a3 loscil 1, kcps2, ifno, ibascps,0,1,2 ; mono AIFF sample without loop
>  a4 = a3
> 
>  skipstereo:
>   ; apply the envelope
> 
> Ben Collver wrote:
>> I could not get looping to work using loscil.
>>
>> The manual states "If sampling reaches the sustain loop endpoint and
>> looping is in effect, the point of sampling will be modified and loscil
>> will continue reading from within that loop segment."
>>
>> How do I set it so that looping is in effect?  Would someone show me an
>> example orchestra and score?
>>
>> Thank you,
>>
>> Ben
> 

-- 
Music that's "Fake but Accurate"!
Web page: http://prodgers13.home.comcast.net
Podcast: http://podcast1024.libsyn.com
Another Podcast: http://BumperMusic.blogspot.com
Music: http://www.soundclick.com/PrentRodgers

Date2006-04-21 18:05
From"Aidan Collins"
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-04-21 20:42
FromTobiah
SubjectRe: looping in loscil?
Aidan Collins wrote:
> Not to change the subject in this thread,
> 
> but am I right in thinking that most Csounders consistently use the
> diskin family of opcodes instead of loscil?
> diskin seems much more straightforward to use and I've never had a
> problem with it.

I use loscil quite a bit with sets of samples from different
ranges of an instrument.  You can record a dozen or so notes
across the range of a guitar for instance, into .aiff files
that have their base frequency correctly set in the 'inst'
chunk of the file.  loscil can then be used to play the sample
at the proper rate in order to create the requested pitch.
You still have to tell loscil which sample is the closest to
the disired pitch.

loscil also does the looping thing, but in my opinion this
technique which saves some hard drive space in exchange for
horrible sounds is not worth it anymore.  You could record
all 88 notes of a piano to their full duration without using
up a dreadful amount of disk space.  I guess that looping
would be useful in the cases where the end decay of an
instrument can not be adequately represented by simply
fading out the sound, or if for some reason you wanted
to sustain a banjo note.

Tobiah

Date2006-04-22 00:37
FromPrent Rodgers
SubjectRe: looping in loscil?
Samples work great with wind instruments. Some examples recently at 
http://bumpermusic.blogspot.com with brass instruments. How else would 
you hold a note for 30 seconds? These samples are about 5 seconds long, 
with twelve per octave, and I can have a chord last as long as I want.

Tobiah wrote:

> loscil also does the looping thing, but in my opinion this
> technique which saves some hard drive space in exchange for
> horrible sounds is not worth it anymore.  You could record
> all 88 notes of a piano to their full duration without using
> up a dreadful amount of disk space.  I guess that looping
> would be useful in the cases where the end decay of an
> instrument can not be adequately represented by simply
> fading out the sound, or if for some reason you wanted
> to sustain a banjo note.
> 
> Tobiah

-- 
Music that's "Fake but Accurate"!
Web page: http://prodgers13.home.comcast.net
Podcast: http://podcast1024.libsyn.com
Another Podcast: http://BumperMusic.blogspot.com
Music: http://www.soundclick.com/PrentRodgers

Date2006-04-22 16:08
FromAnthony Kozar
SubjectRe: looping in loscil?
Ben:  Check to make sure that when you run Csound (5.0x, I assume) that you
are seeing a message like "libsndfile-1.0.13".  If your Csound 5 was not
compiled with libsndfile 1.0.13 or newer, then loscil does not support loop
points.

Everyone:  Since loscil depends on metadata stored in the sound file and
most of us probably do not have access to commercial sample editors, maybe
it would be a good idea to develop a Csound utility that can add or change
loop points, base frequency, etc. to the sound files that we create
ourselves?

Anthony Kozar
anthonykozar AT sbcglobal DOT net


Prent Rodgers wrote on 4/21/06 11:06 AM:

> oscilloscope looping doesn't always do what you think it should. I use
> it extensively in my Csound work and have learned to avoid the quirks.
> If you want to use looping, the format has to be .aif, not .wav. I use a
> program called Awave Studio to correct the loop points, which are
> notoriously tough to get right. http://www.fmjsoft.com/awavestudio.html
> has it for sale.


> Ben Collver wrote:
>> I could not get looping to work using loscil.
>> 
>> The manual states "If sampling reaches the sustain loop endpoint and
>> looping is in effect, the point of sampling will be modified and loscil
>> will continue reading from within that loop segment."
>> 
>> How do I set it so that looping is in effect?  Would someone show me an
>> example orchestra and score?

Date2006-04-22 16:25
FromBen Collver
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-04-22 17:38
FromAnthony Kozar
SubjectRe: looping in loscil?
Ben, that is great news!  I hope that your utility will be able to run on
all of Csound's supported platforms.

I remember that you put some work into getting Csound 4 to compile on a BSD
distro.  I would be very curious to know if Csound 5 can be built without
much trouble on the BSDs if you ever have some spare time and want to try.
Csound 5 has not been tested at all on Unixes other than Linux and OS X
AFAIK.

Thanks.

Anthony Kozar
anthonykozar AT sbcglobal DOT net


Ben Collver wrote on 4/22/06 11:25 AM:

> I am making a utility to edit loop points in audio files.  I can use sox
> for all my other audio file manipulation.  I was going to wait until my
> utility was complete before responding to this thread.  I was also going
> to do some more testing of loscil.  I am using csound4.

Date2006-04-22 18:11
FromBen Collver
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-04-25 21:25
FromTobiah
SubjectRe: looping in loscil?
Ben Collver wrote:
> I am making a utility to edit loop points in audio files. 

There used to be a sound editor called DAP that could do this.

Come to think of it, it seems that soundfonts really make loscil
unnesessary.  I think that any good soundfont editor should have
the ability to edit loop points.

Date2006-04-25 23:25
FromBen Collver
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-04-26 01:47
FromErik de Castro Lopo
SubjectRe: looping in loscil?
Ben Collver wrote:

> I am making progress on my AIFF/AIFC code, but it is not finished yet.

libsndfile (http://www.mega-nerd.com/libsndfile/) has some work
(by John ffitch) to add support for AIFF loop chunks. It also
supports WAV loop chunks using the same API.

If that doesn't suit your needs, maybe you could help improve it.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
The Myth of Islamic Tolerance
http://answering-islam.org.uk/Shamoun/badawi_tolerance.htm

Date2006-04-26 03:01
FromBen Collver
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-04-26 03:33
FromErik de Castro Lopo
SubjectRe: looping in loscil?
Ben Collver wrote:

> Interesting!
> 
> How do I use libsndfile to add loop chunks to an AIFF file?

The currently supported looping is instrument loops like we are
talking about in this thread, not the ReCycle/frum loop type
things. 

Unfortunately i haven't got around to documenting this stuff
yet, but if you grab the source code tarball from the libsndfile
web page, a combination of looking at sndfile.h and looking
at the function instrument_text() in the file examples/command_test.c
should get you started.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
Al Taqiyya
http://www.ci-ce-ct.com/Feature%20articles/02-12-2002.asp
http://www.geocities.com/bharatvarsha1947/January_2003/destroykafirs.htm

Date2006-05-09 05:28
FromBen Collver
SubjectRe: looping in loscil?
AttachmentsNone  

Date2006-05-13 16:42
FromBen Collver
SubjectANN: sfubar-3 command-line soundfont2/wav/aif editor
AttachmentsNone  

Date2006-05-13 20:24
FromAnthony Kozar
SubjectRe: ANN: sfubar-3 command-line soundfont2/wav/aif editor
This is great, Ben.  Thanks!!

I will attempt to compile and run your utility on my computers.

Regarding the sustain loop:  in order to get a score event to behave like a
Midi note (with a release segment), I was going to suggest that you can use
the xtratim opcode.  But the manual says this is only for real-time events.

However, I remembered the following change in Csound 5.00:

> MIDI-style extra time and release (xtratim, linsegr, etc.) is now
>         also possible with score notes

So, I think what you want to do is possible now in Csound 5, if you want to
try compiling it for BSD.  (Note: the manual page for xtratim needs to be
updated).

Alternatively, since you know the length of the release at the beginning of
the note, I think that you can just change p3 (p-fields are writable in
instrument code, but only at i-time I think).  The special Midi envelopes
won't work this way but it is a start.

Anthony Kozar
anthonykozar AT sbcglobal DOT net

Ben Collver wrote on 5/13/06 11:42 AM:

> I added AIF support to sfubar, and it is able to add loop points to AIF
> files.  I have tested it on NetBSD/i386, NetBSD/sparc64, and Windows XP
> Pro.  I put the source code in the public domain.
> 
> It can be fetched at one of the following:
> http://terrorpin.net/~ben/docs/alt/music/soundfont/sfubar-3.tgz
> http://terrorpin.net/~ben/docs/alt/music/soundfont/sfubar-3.zip
> 
> Cheers,
> 
> Ben
> 
> 
> p.s.
> 
> My remaining problem is figuring out how to get csound4 to continue
> through a wavetable after ending the sustain loop.  Csound seems to
> abruptly cut off at the end of the sustain loop.

Date2006-05-22 00:01
FromBen Collver
SubjectRe: ANN: sfubar-3 command-line soundfont2/wav/aif editor
AttachmentsNone