당사 팬 페이지에 가입하십시오
- 조회수:
- 5966
- 평가:
- 게시됨:
- 2013.03.01 13:38
- 업데이트됨:
- 2016.09.23 09:03
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
A class to control the MIDI device is located in the IncMIDI.mqh file. The example of its use is represented in the eMIDI.mq5 file.
The order of using the CMIDI class
- Connect a file with a class:
#include <IncMIDI.mqh>
- Declare a class:
CMIDI m;
- Transfer music program using the SetMusic(string & aMusic[]) method.
- Enable playback using the Play(bool aSynch=true) method. If aSynch is true, play is performed in a synchronous mode in the cycle with pauses using the Sleep() function. If aSynch is false, play is performed in a synchronous mode, besides you can stop play using the Stop() method. To work in a synchronous mode from the OnChartEvent() function of the Expert Advisor the ChartEvent() method must be called.
- Call the Stop() method upon completion of work. It is necessary for the MIDI device closing, otherwise to rerun it you should restart the terminal.
Music program
Music program is recorded in the string array. In one array element is written a list of actions. Actions are written by a comma. At first a command, an equal sign and a command value are written. The following commands are available:
- Tick - time in milliseconds through which all the commands of one array element will be performed. It defines the tempo with which the play is performed.
- Volume - the volume level, from 0 to 100.
- VolumeL - the left channel volume level, from 0 to 100.
- VolumeR - the right channel volume level, from 0 to 100.
- Instrument - selection of the music instrument, from 0 to 127.
- NoteDN - press a key. Number 60 corresponds to "do" note of the main octave, 61 - to "C sharp", 62 - to "re", etc.
- NoteUP - release a key. For several instruments you cannot use release a key, the sound fades away itself, and for some keys it is obligatory to press.
It is possible to take chords, for example, "NoteDN=57, NoteDN=60, NoteDN=64". A possible parallel play on several instruments, for example, "Instrument=1, NoteDN=60, Instrument=123, NoteDN=60". Different instruments' volume can not be changed, all is played on the same volume, but you can change the volume of different parts of playing, for example:
"Tick=1500, Instrument=123, Volume=100, NoteDN=60", "VolumeL=0, VolumeR=100, NoteDN=64", "VolumeL=100, VolumeR=0, NoteDN=57", "Volume=50, NoteDN=67, NoneDN=57", "Volume=25, NoteDN=64, NoneDN=67"
The CMIDI class methods
- void ChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) - called from the function when using play in an asynchronous mode.
- void Play(bool aSynch=true) - enable play. If aSynch is false, from the OnChartEvent function the ChartEvent() method must be called.
- void Stop() - stop play in an asynchronous play. Stop play and close the device.
- void SetMusic(string & aMusic[]) - sending an array with a music program.
- void SetEventID(ushort aID) - setting a number of a custom event. It is necessary when using play in an asynchronous mode. It is not necessary to call, default value is 1.
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/1555
![MD5 Hash](https://c.mql5.com/i/code/library.png)
Calculation of 32 digit string MD5-hash from transmitted byte array
![EMAPredictive3](https://c.mql5.com/i/code/indicator.png)
The Moving Average drawn on the basis of the EMA algorithm. A linear interpolation of two different period EMA is used
![i-Friday_Sig](https://c.mql5.com/i/code/indicator.png)
Signals of entries and exits on the system "Friday effect"
![Narrowest Range Signal](https://c.mql5.com/i/code/indicator.png)
The narrowest range indicator defines the moments when the market is in the "compressed" state that says of the future breakthrough in this or that side