Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Tocar archivos Midi

Posted on 1999-07-30
2
Medium Priority
?
167 Views
Last Modified: 2010-04-04
Quisiera saber como hago para que cuando presione un boton pueda escuchar archivos midi  ?
0
Comment
Question by:Jleal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 1392013
Hi,
here is how:
{remember to add mmsystem to the uses section at the top of the unit.}


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,mmsystem,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

Function PlayMidiFile(FileName:string):word;
var  //note i need to add MMSYSTEM to the uses section
wdeviceid:integer;
dwreturn:word;
mciOpen:tmci_open_parms;
mciPlay:tmci_play_parms;
mciStat:tmci_status_parms;
mciseq:tmci_seq_set_parms;
begin
    // Open the device by specifying the device and filename.
    // MCI will attempt to choose the MIDI mapper as the output port.

    mciopen.lpstrDeviceType:='sequencer';
    mciopen.lpstrElementName:=pchar(filename);

    dwReturn:=mciSendCommand($0,mci_open,mci_open_type OR
mci_open_element,longint(@mciopen));
    if dwreturn<>0 then result:=dwreturn else
    begin
      // The device opened successfully; get the device ID.
      wDeviceID:=mciOpen.wDeviceID;
      // Check if the output port is the MIDI mapper.
      mciStat.dwItem:= MCI_SEQ_STATUS_PORT;
      dwReturn:=mciSendCommand(wDeviceID, MCI_STATUS,
MCI_STATUS_ITEM,longint(@mciStat));
      if dwreturn<>0 then
      begin
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        result:=dwreturn;
      end else
      begin
        // Begin playback. The window procedure function for the parent
        // window will be notified with an MM_MCINOTIFY message when
        // playback is complete. At this time, the window procedure closes
        // the device.
        mciPlay.dwCallback:=application.Handle;
        dwReturn:=mciSendCommand(wDeviceID, MCI_PLAY,
MCI_NOTIFY,longint(@mciPlay));
        if dwreturn<>0 then
        begin
          mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
          result:=dwreturn;
        end;
      end;
    end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
PlayMidiFile('c:\my.midi');

// or you could do
//opendialog1.execute;  //and find a midi file then
//PlayMidiFile(opendialog1.filename);
end;

end.



Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 1392014
Hello..i have gave you the answer ..

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question