Re: Karl, I need to understand your Timer!



On Sat, 13 Jun 2009 17:13:03 +0200, "Schmidt" <sss@xxxxxxxxx> wrote:


"MM" <kylix_is@xxxxxxxxxxx> schrieb im Newsbeitrag
news:73b7355ovggpocjoc06mmr6jadgh7dh4hk@xxxxxxxxxx

I have tried exactly what you describe with timeBeginPeriod 1
and timeEndPeriod 1, but it makes no difference. As soon as
I start to move the form, or scroll a scrollbar, the output stops.

The timeBeginPeriod/..endperiod-calls have nothing to do
with your sound-blocking issues in case your GUI is
"touched".

They are only there, to (normally) increase the accuracy
ot the multimedia-timer - but they also have that nice side-
effect on the sleep-call, which then is able to work below 15msec
granularity - just what you need IMO for your (wait-)purposes.

Your blocking-issues (at least on Win98) were not solvable
as I read in your other thread - the callback-approach, posted
by Alfie [UK] is a nice idea - but it seems to work only on
XP currently, if I read that correctly.

Hmm, maybe time now, to really think about a threaded
approach <g>.

But be aware, that if you want to do it properly, you will
have to move everything that's Midi-related into a Class
then (probably not that much of a problem) - but the
larger effort would be, that this Class (which later on runs
on its own thread) needs to communicate with your GUI
in an asynchronous way (at least as long as your loops
are running, which play a current continuous stream).
And that will cause side-effekts (coding-effort) on how
you need to work then with your GUI (rendering-) code.

So, are there more actions than playing a current stream
(wherever that stream comes from) which currently
need an "unblocking" - or is that the only one.

And if it is - in what format do you currently hold your
Data for a given Stream - if in an (userdefined) Array -
how large is it in the worst-case (does that structure
already contain the maximum of all 16-possible channels?).

Or do you organize each channel in a separate Array.

And what is with interaction whilst a stream is playing?
Start-Stop is clear - but do you want to allow live-playing
(or even additional recording) whilst a current stream is
played within the thread? I assume yes, if your App acts
something like a sequencer - but if Not, that would ease
the threading-design a bit.

Olaf

Thanks, Olaf. Here's an overview:

So, the MIDI data is held in a UDT of the following Type:

Type MIDIEventType
DeltaTime As Long
status As Byte
data1 As Byte
data2 As Byte
data3 As Byte
bytepointer As Long
End Type

Public MIDEventQueue() As MIDIEventType

The UDT is ReDimmed according to need as events are read from the MIDI
file and pumped into it. Thus the array could hold 1 event or 30,000.
There IS a limit, since it is only using memory, but I can hold enough
data for a Beethoven Sonata, for instance, which is more than enough
for the purpose of the app (i.e. to practise riffs on the piano!)

The Playback routine is started. Basically, this is a loop from
pointer=0 to UBound(MIDEventQueue)

During the Playback the program also "plays" the key on a virtual
keyboard (see picture at
http://www.littletyke.myzen.co.uk/ktn/index.html)

So, each midiOutShortMsg is preceded by PlayOrReleaseKey.

It all works VERY nicely! The virtual keys are exactly in sync with
the MIDI output. Just what I wanted it to do. But the slight fly in
the ointment is the blocking that occurs when moving the main form, or
the keyboard, or scrolling either the grid or scrolling the keyboard.

It is not a MAJOR problem, since the whole purpose of this app is to
help orientation around a piano or organ keyboard for those who have
never learned to sight-read successfully.

Actually, the *original* purpose was to provide a driver for an array
of LEDs (physical hardware LEDs) along a piano keyboard (see
http://www.littletyke.myzen.co.uk/vb6tobasicstamp2/html/the_application.html)
and that is the next stage on my ToDo list. That is where
PlayOrReleaseKey (see above) will be augmented by: SwitchLEDOnOff,
whereupon a suitable message is sent out of the serial port to the
BASIC Stamp and the BS causes the appropriate LED to be lighted (or
switched off).

Well it ~was~ intended as "only" a driver originally, but has turned
into a full-blown app in its own right over the past 18 months.

MM
.



Relevant Pages

  • XP and Windows 7: Picture in ActiveX control is corrupted
    ... I am testing my music/MIDI app and now have the facility to test on ... My app uses a scrolling viewport that allows a ... On Windows 7 Beta when the viewport is scrolled, ... and look at the right-hand side of the virtual keyboard, ...
    (microsoft.public.vb.general.discussion)
  • RE: XP and Windows 7: Picture in ActiveX control is corrupted
    ... not an issue with Windows 7... ... My app uses a scrolling viewport that allows a ... and look at the right-hand side of the virtual keyboard, ... As soon as any operation (e.g. switch to another app, ...
    (microsoft.public.vb.general.discussion)
  • Re: Keyboard navigation on RISC OS?
    ... accidentally selected file etc. all with the keyboard. ... properly, it becomes a selling point - but without that proper ... potential developers of the shared source stream can see what those ...
    (comp.sys.acorn.misc)
  • Re: Cursor Movement Not Smooth
    ... suddenly there was a long system beep (it's the ... Also when I use the keyboard Left/Right arrow & Up/Down arrow keys to ... one of the checkboxes say "Use smooth scrolling". ...
    (microsoft.public.windowsxp.general)
  • Re: Links
    ... pressing command on the keyboard allows scrolling by simply moving the mouse up and down. ... As an artist, spend a lot of time with a mouse, not had a problem with my wrists and hands. ...
    (alt.html)

Quantcast