473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Midi file: this is very very very difficult !

tom
Hallo,

I need help on MIDI file,

and precisely about retrieving
few note values
(mainly the "Velocity" value,
corrisponding to the intensity
of a played note)
while the MIDI is playing.

(If you don't kow,
the "Velocity" value is a value
stored in the MIDI file).

- - - - -

I'm using DirectX (Dx7vb.dll)
to manage (Start, Stop ...)
the MIDI file,

but if my problem can be solved
also without using DirectX
or by using an external (free)
..dll or .ocx,
it is good the same.

- - - - -

Scenario (very simple scenario):

I'm playing a MIDI file using
the DirectX commands
(by the Dx7vb.dll file;
if you have DirectX8 or DirectX9
things should not be very different).
No problem in this.

Now I want to retrieve some "live" information
while the Midi file is playing,
so I decide it cold be a good solution
to implement a 'callback' function.
I found a snippet of code
that allows me to retrieve the information
about the Start, the Stop...
of the Midi file.
No problem in this.

See below, if you like,
the snippet of code that performs the
'callback' task
(note: if you don't already have
on your project
the lines of code that allow you
to play a Midi file,
this solely snippet of code won't work;
if you want that playing code
I'll provide you with it).

- - - - -

BUT..

I don't want to retrieve
the Start, the Stop...
of the Midi file.
I want to retrieve some information
about the current played notes
(most of all their Velocity value).
I presume that I need to use the

DMUS_NOTE_PMSG type
or
DMUS_CURVE_PMSG type
and their
..Velocity sub-parameter
also
I should indicate the channel
I'm retrieving the played notes from

(note:
in a 'standard' Midi file there are 16 channels;
if it is not a 'standard' Midi
you have 1 big channel only,
but my program splits it
in 16 separated channels
so to ultimately have
a 16 channels Midi file)
also
when I build the 'callback' strucutre
I think I have to change the parameter
DMUS_NOTIFY_ON_SEGMENT
of
myPerf.AddNotificationType DMUS_NOTIFY_ON_SEGMENT
(see below the snippet of code,
under the sections 3 and 5 )
and use another parameter,
(maybe the
DMUS_NOTIFY_ON_MEASUREANDBEAT parameter ?)

- - - - -
If you need more explanations
I'll povide you with links where to download

the Dx7vb.dll,
the playing code,
a 'standard' Midi file
more details...
- - - - -
I previously post this request in several NGs,
but I got no answers
(= nobody answered me).
I don't know because it is a difficult task
or because those NGs are poorly populated.

==== ==== ==== ==== =====
==== ==== ==== ==== =====
Callback snippet of code.
''' 1 On the References section
' of your VB project
' you have to absolutely
' reference the Dx7vb.dll file
' (you find it under the 'Project' menu),



''' 2 On the Declarations section

'among the other declarations, you have to add these:
Implements DirectXEvent 'creates the "DirectXEvent_DXCallback"
function.
Private myEvent As Long 'An Event handle
Dim myPerf As DirectMusicPerformance


''' 3 On the Load or Initialize or whatever you like event,
but before you start playing the Midi file
'among the other initialization stuff, you have to add these:
Set myPerf = Dx.DirectMusicPerformanceCreate
Call myPerf.Init(Nothing, hwnd)
myPerf.SetPort -1, 1
myPerf.AddNotificationType DMUS_NOTIFY_ON_SEGMENT 'relay messages
about the segment
myEvent = Dx.CreateEvent(Me)
myPerf.SetNotificationHandle myEvent 'used to identify the messages


''' 4 On the DirectXEvent_DXCallback
'Private Sub DirectXEvent_DXCallback(ByVal eventid As Long)

If eventid = myEvent Then 'the message is our message

Dim myMSG As DMUS_NOTIFICATION_PMSG

Select Case myMSG.lNotificationOption
Case DMUS_NOTIFICATION_SEGABORT
Debug.Print "MESSAGE: DMUS_NOTIFICATION_SEGABORT"
Case DMUS_NOTIFICATION_SEGEND
Debug.Print "MESSAGE: DMUS_NOTIFICATION_SEGEND"
Case DMUS_NOTIFICATION_SEGSTART
Debug.Print "MESSAGE: DMUS_NOTIFICATION_SEGSTART"
Case Else
Debug.Print "MESSAGE: Unknown"
End Select

End If

'End Sub



''' 5 On the Unload event

'now we discard all
myPerf.RemoveNotificationType DMUS_NOTIFY_ON_SEGMENT
Dx.DestroyEvent myEvent
If ObjPtr(dmSeg) Then Set dmSeg = Nothing
If ObjPtr(dmLoader) Then Set dmLoader = Nothing
If ObjPtr(Dx) Then Set Dx = Nothing


==== ==== ==== ==== =====
==== ==== ==== ==== =====
Nov 20 '05 #1
0 1711

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robin Hollenstein | last post by:
How can I convert (with the Java Sound API) a javax.sound.midi.Sequence to a javax.sound.sampled.AudioInputStream? Please help me I need java source code. R. Hollenstein
3
by: Anton Vredegoor | last post by:
Recently there has been a lot of progress concerning the integration of midi into python. A midipy.cpp for Python20 is found and various compiling efforts having been undertaken to compile it for...
0
by: Max M | last post by:
If anybody is interrested in Midi, but are not on the Python Midi list, I will just notify that I have released the first version of a high level midi package for Python. It is fully functional....
11
by: Kuba Araszkiewicz | last post by:
Hello! I have to write a program, which would convert midi files to notes, notes to midi files and which would make one MIDI file from two different. I'm totally lame in C (and any other...
2
by: david | last post by:
1.I am considering doing a midi file generator for my 4th year project in B.SC. 2.I would do it using c language, but i'm not sure abou t the level of difficulyt involved 3.Basically, the...
1
by: tim | last post by:
Someone using Python Midi Package from http://www.mxm.dk/products/public/ lately? I want to do the following : write some note events in a midi file then after doing that, put some controllers...
4
by: sreekant | last post by:
Hi folks I hope someone here might be able to help. I scavenged some info and even code from the net and am trying to write a module that reads a text file and spits out a midi file. So far I...
9
by: outstretchedarm | last post by:
How exactly does HTML/Javascript handle playing midi files? Does it have a player imbedded in it? Or does it borrow from the computer's midi player? How could you make a webpage play certain...
6
by: Gilly | last post by:
Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.