Rush problem with audio-visual code

I have encountered some puzzling interactions between Rush() and code that I
have written to present stimuli that have simultaneous auditory and visual
components. Here is the critical chunk of code that presents the stimulus
after the auditory waveform (beep) and the specifications for the animation
have been generated and loaded into memory.

nframes = length(signal);
evTimes = zeros(1, nframes);
frame = 0; % Pre-allocate storage before Rush
code = {
'Snd(''Play'', beep, audioFreq);'
'SCREEN(w, ''WaitBlanking'');'
'GetSecs(evTimes, 1);'
'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect(lineRect,
posSig(1), 600));'
'for frame = 2:nframes;'
'SCREEN(w, ''WaitBlanking'');'
'GetSecs(evTimes, frame);'
'SCREEN(''CopyWindow'', lineErase, w, lineRect,
OffsetRect(lineRect, posSig(frame-1), 600));'
'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect(lineRect,
posSig(frame), 600));'
'end'
};
Snd('Close'); % Ensure that Snd is loaded
priorityLevel=MaxPriority(w, 'WaitBlanking', 'SND', 'GetSecs');
% Rush(code, priorityLevel);
Rush(code, 0); % On some machines, this does not work with priority=2

The call to MaxPriority returns 2. However, as the comment on the last line
suggests, on some machines this does not work. Right now, I am sitting at a
PC running Windows 2000, Matlab 6.5 Release 13, and the latest version of
PTB for Windows and the code only works properly if the Rush priority is 0.
If the priority is 2, there is a auditory click at the start and then
silence until the end of the animation at which point the full auditory
signal is played. If the priority is 1, there is again a click at the
start, but now the auditory signal starts playing midway through the visual
animation. However, on an older Windows 98 machine (running the same Matlab
and PTB), the stimulus is presented correctly with priority = 2.

Can anyone provide any insights about what the problem is?

Ted Wright
Denis,

I have been looking into this. Is there any way to determine anything about
which version of the Windows operating Matlab and PTB are running under?

Ted

On Fri, 25 Jun 2004, Denis Pelli wrote:

> dear ted
>
> i wrote the mac version, not the windows version. however, it is
> correct to interpret this as a bug in MaxPriority. Note that
> MaxPriority is pure M code, so you can fix it, and post a fixed
> version here to help others.
>
> what priority a hardware process can run at is nightmarishly hard to
> figure out. this information is rarely supplied by anybody, and often
> depends on the model of the computer and the version of the operating
> system. most of the rules in MaxPriority are based on a mixture of
> manual testing, some guidance from operating system documentation,
> and a lot of intuitive guessing for how to generalize to untested
> cases.
>
> best
>
> denis
>
>
>
> >Jeroen,
> >
> >Thank you for the response. I guess what puzzles me is why MaxPriority does
> >not reflect this limitation and why it only occurs for some versions of the
> >Windows OS.
> >
> >Ted Wright
> >
> >On Fri, 25 Jun 2004, Jeroen Benjamins wrote:
> >
> >> Hello Ted,
> >>
> >> I think there's something in the documenation of the SND command
> >> (type 'help SND') where it says that the maximum priority at which
> >> sounds can still be played is 0.5 (that's for Mac, so for windows it
> >> would be 0). Higher priorities block your sound output. That's why
> >> only priority 0 works in your situation.
> >>
> >> best regards
> >> Jeroen Benjamins
> >>
> >>
> >> --- In psychtoolbox@yahoogroups.com, "Charles E. (Ted) Wright"
> >> <cew@a...> wrote:
> >> > I have encountered some puzzling interactions between Rush() and
> >> code that I
> >> > have written to present stimuli that have simultaneous auditory and
> >> visual
> >> > components. Here is the critical chunk of code that presents the
> >> stimulus
> >> > after the auditory waveform (beep) and the specifications for the
> >> animation
> >> > have been generated and loaded into memory.
> >> >
> >> > nframes = length(signal);
> >> > evTimes = zeros(1, nframes);
> >> > frame = 0; % Pre-allocate storage before Rush
> >> > code = {
> >> > 'Snd(''Play'', beep, audioFreq);'
> >> > 'SCREEN(w, ''WaitBlanking'');'
> >> > 'GetSecs(evTimes, 1);'
> >> > 'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect
> >> (lineRect,
> >> > posSig(1), 600));'
> >> > 'for frame = 2:nframes;'
> >> > 'SCREEN(w, ''WaitBlanking'');'
> >> > 'GetSecs(evTimes, frame);'
> >> > 'SCREEN(''CopyWindow'', lineErase, w, lineRect,
> >> > OffsetRect(lineRect, posSig(frame-1), 600));'
> >> > 'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect
> >> (lineRect,
> >> > posSig(frame), 600));'
> >> > 'end'
> >> > };
> >> > Snd('Close'); % Ensure that Snd is loaded
> >> > priorityLevel=MaxPriority(w, 'WaitBlanking', 'SND', 'GetSecs');
> >> > % Rush(code, priorityLevel);
> >> > Rush(code, 0); % On some machines, this does not work with
> >> priority=2
> >> >
> >> > The call to MaxPriority returns 2. However, as the comment on the
> >> last line
> >> > suggests, on some machines this does not work. Right now, I am
> >> sitting at a
> >> > PC running Windows 2000, Matlab 6.5 Release 13, and the latest
> >> version of
> >> > PTB for Windows and the code only works properly if the Rush
> >> priority is 0.
> >> > If the priority is 2, there is a auditory click at the start and
> >> then
> >> > silence until the end of the animation at which point the full
> >> auditory
> >> > signal is played. If the priority is 1, there is again a click at
> >> the
> >> > start, but now the auditory signal starts playing midway through
> >> the visual
> >> > animation. However, on an older Windows 98 machine (running the
> >> same Matlab
> >> > and PTB), the stimulus is presented correctly with priority = 2.
> >> >
> >> > Can anyone provide any insights about what the problem is?
> >> >
> >> > Ted Wright
> >>
> >>
> >>
> >>
> >>
> >> http://psychtoolbox.org
> >> POST a message to: psychtoolbox@yahoogroups.com
> >> UNSUBSCRIBE by sending a blank message to:
> >> psychtoolbox-unsubscribe@yahoogroups.com
> >> Yahoo! Groups Links
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >http://psychtoolbox.org
> >POST a message to: psychtoolbox@yahoogroups.com
> >UNSUBSCRIBE by sending a blank message to:
> >psychtoolbox-unsubscribe@yahoogroups.com
> >Yahoo! Groups Links
> >
> >
> >
> >
>
>
>
>
> http://psychtoolbox.org
> POST a message to: psychtoolbox@yahoogroups.com
> UNSUBSCRIBE by sending a blank message to:
> psychtoolbox-unsubscribe@yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
dear ted

in the Mac version there are SCREEN Prefs that allow you to find out
about the OS and hardware. I suspect that feature is not implemented
in the Windows version. Sorry.

best

denis


>Denis,
>
>I have been looking into this. Is there any way to determine anything about
>which version of the Windows operating Matlab and PTB are running under?
>
>Ted
>
>On Fri, 25 Jun 2004, Denis Pelli wrote:
>
>> dear ted
>>
>> i wrote the mac version, not the windows version. however, it is
>> correct to interpret this as a bug in MaxPriority. Note that
>> MaxPriority is pure M code, so you can fix it, and post a fixed
>> version here to help others.
>>
>> what priority a hardware process can run at is nightmarishly hard to
>> figure out. this information is rarely supplied by anybody, and often
>> depends on the model of the computer and the version of the operating
>> system. most of the rules in MaxPriority are based on a mixture of
>> manual testing, some guidance from operating system documentation,
>> and a lot of intuitive guessing for how to generalize to untested
>> cases.
>>
>> best
>>
>> denis
>>
>>
>>
>> >Jeroen,
>> >
>> >Thank you for the response. I guess what puzzles me is why MaxPriority does
>> >not reflect this limitation and why it only occurs for some versions of the
>> >Windows OS.
>> >
>> >Ted Wright
>> >
>> >On Fri, 25 Jun 2004, Jeroen Benjamins wrote:
>> >
>> >> Hello Ted,
>> >>
>> >> I think there's something in the documenation of the SND command
>> >> (type 'help SND') where it says that the maximum priority at which
>> >> sounds can still be played is 0.5 (that's for Mac, so for windows it
>> >> would be 0). Higher priorities block your sound output. That's why
>> >> only priority 0 works in your situation.
>> >>
>> >> best regards
>> >> Jeroen Benjamins
>> >>
>> >>
>> >> --- In psychtoolbox@yahoogroups.com, "Charles E. (Ted) Wright"
>> >> <cew@a...> wrote:
>> >> > I have encountered some puzzling interactions between Rush() and
>> >> code that I
>> >> > have written to present stimuli that have simultaneous auditory and
>> >> visual
>> >> > components. Here is the critical chunk of code that presents the
>> >> stimulus
>> >> > after the auditory waveform (beep) and the specifications for the
>> >> animation
>> >> > have been generated and loaded into memory.
>> >> >
>> >> > nframes = length(signal);
>> >> > evTimes = zeros(1, nframes);
>> >> > frame = 0; % Pre-allocate storage before Rush
>> >> > code = {
>> >> > 'Snd(''Play'', beep, audioFreq);'
>> >> > 'SCREEN(w, ''WaitBlanking'');'
>> >> > 'GetSecs(evTimes, 1);'
>> >> > 'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect
>> >> (lineRect,
>> >> > posSig(1), 600));'
>> >> > 'for frame = 2:nframes;'
>> >> > 'SCREEN(w, ''WaitBlanking'');'
>> >> > 'GetSecs(evTimes, frame);'
>> >> > 'SCREEN(''CopyWindow'', lineErase, w, lineRect,
>> >> > OffsetRect(lineRect, posSig(frame-1), 600));'
>> >> > 'SCREEN(''CopyWindow'', lineDraw, w, lineRect, OffsetRect
>> >> (lineRect,
>> >> > posSig(frame), 600));'
>> >> > 'end'
>> >> > };
>> >> > Snd('Close'); % Ensure that Snd is loaded
>> >> > priorityLevel=MaxPriority(w, 'WaitBlanking', 'SND', 'GetSecs');
>> >> > % Rush(code, priorityLevel);
>> >> > Rush(code, 0); % On some machines, this does not work with
>> >> priority=2
>> >> >
>> >> > The call to MaxPriority returns 2. However, as the comment on the
>> >> last line
>> >> > suggests, on some machines this does not work. Right now, I am
>> >> sitting at a
>> >> > PC running Windows 2000, Matlab 6.5 Release 13, and the latest
>> >> version of
>> >> > PTB for Windows and the code only works properly if the Rush
>> >> priority is 0.
>> >> > If the priority is 2, there is a auditory click at the start and
>> >> then
>> >> > silence until the end of the animation at which point the full
>> >> auditory
>> >> > signal is played. If the priority is 1, there is again a click at
> > >> the
>> >> > start, but now the auditory signal starts playing midway through
>> >> the visual
>> >> > animation. However, on an older Windows 98 machine (running the
>> >> same Matlab
>> >> > and PTB), the stimulus is presented correctly with priority = 2.
>> >> >
>> >> > Can anyone provide any insights about what the problem is?
>> >> >
>> >> > Ted Wright
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> http://psychtoolbox.org
>> >> POST a message to: psychtoolbox@yahoogroups.com
>> >> UNSUBSCRIBE by sending a blank message to:
>> >> psychtoolbox-unsubscribe@yahoogroups.com
>> >> Yahoo! Groups Links
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> >
>> >http://psychtoolbox.org
>> >POST a message to: psychtoolbox@yahoogroups.com
>> >UNSUBSCRIBE by sending a blank message to:
>> >psychtoolbox-unsubscribe@yahoogroups.com
>> >Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>> http://psychtoolbox.org
>> POST a message to: psychtoolbox@yahoogroups.com
>> UNSUBSCRIBE by sending a blank message to:
>> psychtoolbox-unsubscribe@yahoogroups.com
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>
>
>
>
>http://psychtoolbox.org
>POST a message to: psychtoolbox@yahoogroups.com
>UNSUBSCRIBE by sending a blank message to:
>psychtoolbox-unsubscribe@yahoogroups.com
>Yahoo! Groups Links
>
>
>
>