[squeak-dev] Bad loop parameters in AIFF [Repost without large attachment]

David O'Toole deeteeoh1138 at gmail.com
Sat Feb 5 14:41:09 UTC 2022


Thank you so much for your help Karl!


On Sat, Feb 5, 2022 at 9:37 AM karl ramberg <karlramberg at gmail.com> wrote:

> Cool
>
> Best,
> Karl
>
> On Sat, Feb 5, 2022 at 3:32 PM David O'Toole <deeteeoh1138 at gmail.com>
> wrote:
>
>> "markers last last" <---- this isn't correct, it should be "markers
>> second last" as it is definitely legitimate for AIFF files to contain more
>> than two markers. Indeed with the following changeset, I get a working (if
>> somewhat wonky and still needing to be debugged) instrument.
>>
>> vCello := SampledInstrument readSimpleInstrument: 'cello' fromDirectory:
>> '/home/dto/sessions/orch.mosaic'.
>> vCello playChromaticRunFrom: 10 to: 40.
>> (vCello soundForMidiKey: 20 dur: 8.0 loudness: 0.5) play.
>>
>> On Sat, Feb 5, 2022 at 9:03 AM karl ramberg <karlramberg at gmail.com>
>> wrote:
>>
>>>
>>> I think there is something wrong with the logic for AIFFFileReader
>>> instance variable isLooped.
>>> I don't see the error if I hard code isLooped to false in method below.
>>>
>>> AIFFFileReader>>readInstrumentChunk: chunkSize
>>> ...
>>> isLooped := sustainMode = 1.
>>> (isLooped and: [markers notNil]) ifTrue: [
>>> ((markers first last > frameCount) or:
>>> [markers last last > frameCount]) ifTrue: [
>>> "bad loop data; some sample CD files claim to be looped but aren't"
>>> isLooped := false]].
>>>
>>> The logic for determining if a sound is looped seems a little
>>> error-prone.
>>>
>>> Loop length in AIFFFileReader is calculated from markers
>>> Markers in 36.aif is #(#(1 '' 44100) #(2 '' 88200) #(3 '' 0) #(4 '' 0)).
>>>
>>> markers := #(#(1 '' 44100) #(2 '' 88200) #(3 '' 0) #(4 '' 0)).
>>> markers last last - markers first last  "How AIFFFileReader calculates
>>> loop length"
>>> -44100
>>>
>>> Best,
>>> Karl
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sat, Feb 5, 2022 at 1:36 PM David O'Toole <deeteeoh1138 at gmail.com>
>>> wrote:
>>>
>>>> Try placing the unzipped "cello f" folder into directory "path_to_foo"
>>>> then:
>>>>
>>>> SampledInstrument readSimpleInstrument: 'cello' fromDirectory:
>>>> 'path_to_foo'
>>>>
>>>> I see your comment about the negative loop length, however this appears
>>>> to be the bug itself---I verified in Snd that the loop points are 44100 and
>>>> 88200.
>>>>
>>>> On Sat, Feb 5, 2022 at 7:08 AM karl ramberg <karlramberg at gmail.com>
>>>> wrote:
>>>>
>>>>> Do you have a short doIt to load these samples ?
>>>>> I'm not sure how you set it up.
>>>>> A quick look at aiffloop.txt I see this:
>>>>> LoopedSampledSound>>samples:loopEnd:loopLength:pitch:samplingRate:
>>>>> 	Receiver: a LoopedSampledSound
>>>>> 	Arguments and temporary variables:
>>>>> 		aSoundBuffer: 	a SoundBuffer(0 0 0 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 1 1 0...etc...
>>>>> 		loopEndIndex: 	0
>>>>> 		loopSampleCount: 	-44100
>>>>>
>>>>> So there will probably be issues with negative number of samples in the loop
>>>>>
>>>>> Best,
>>>>> Karl
>>>>>
>>>>>
>>>>> On Sat, Feb 5, 2022 at 2:46 AM David O'Toole <deeteeoh1138 at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> (Apologies if this is a double post, I think the other will be
>>>>>> rejected on account of the 2+MB AIFF file I attached. Instead I've put up a
>>>>>> Zip file of the AIFFs I'm trying to import, on GDrive:
>>>>>> https://drive.google.com/file/d/16BvtxS9tkIPJRcx-cri1gPGM5p0E7uV_/view?usp=sharing
>>>>>>
>>>>>> Original message:
>>>>>>
>>>>>> I have AIFF files with loop points all set the same, beginning at
>>>>>> sample 44100 and ending at 88200. I am trying to use
>>>>>> SampledInstrument(class)>>#readSimpleInstrument:fromDirectory: to create a
>>>>>> sampled instrument.
>>>>>>
>>>>>> In Snd i can verify the loop points are correct:
>>>>>>
>>>>>> > >(sound-loop-info (open-sound "~/sessions/orch.mosaic/cello
>>>>>> f/36.aif"))
>>>>>> (44100 88200 0 0 0 0 1 1)
>>>>>>
>>>>>> But as you can see in the bug report/screenshot, the end point
>>>>>> becomes 0 somehow when it reaches note 36.aif, resulting in an error. I've
>>>>>> also included the offending .aif file, which might be malformed in some way
>>>>>> I haven't discovered.
>>>>>>
>>>>>> How might I go about debugging this further?
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220205/b76a983f/attachment.html>


More information about the Squeak-dev mailing list