How to use audio toolbox

조회 수: 1 (최근 30일)
David Koenig
David Koenig 2019년 7월 23일
댓글: David Koenig 2019년 8월 1일
Hello. I have audio toolbox and I am trying to cause my Yamaha P120 digital piano to produce the sound of a key strike by sending a message from my laptop to the piano. My code, derived from the Matlab documentation, is:
%===get device information
mididevinfo
%===choose the device
device=mididevice('USB Midi ')
%===choose the channel, note and velocity & make message
channel = 2;
note = 60;
velocity = 64;
msg = midimsg('NoteOn',channel,note,velocity)
%===send the message
midisend(device,msg)
%===turn note on
OnMsg = midimsg('NoteOn',channel,note,velocity);
OffMsg = midimsg('NoteOn',channel,note,0);
OnMsg.Timestamp = 1;
OffMsg.Timestamp = 1;
midisend(device,[OnMsg;OffMsg])
pause(1.5)
midisend(device,OffMsg)
The response is:
MIDI devices available:
ID Direction Interface Name
0 output MMSystem 'Microsoft MIDI Mapper'
1 input MMSystem 'USB Midi '
2 output MMSystem 'Microsoft GS Wavetable Synth'
3 output MMSystem 'USB Midi '
device =
mididevice connected to
Input: 'USB Midi ' (1)
Output: 'USB Midi ' (3)
msg =
MIDI message:
NoteOn Channel: 2 Note: 60 Velocity: 64 Timestamp: 0 [ 91 3C 40 ]
>>
I do not get a response from my piano. I may have problems setting up the piano but in the meantime, can you explain what the "channel" is? I have tried 1,2,3 but get nothing.
Also, I assume that "note" refers to the key number so that 49 would refer to A4.
Thanks.

답변 (1개)

Samatha Aleti
Samatha Aleti 2019년 7월 31일
Hi,
MIDI Message holds the information about audio related action. For the following command
midimsg(‘NoteOn’,channel, note, velocity)
  • NoteOn ‘and channel refers to the kind of action (start playing or stop playing) and the channel
  • note refers to the key that is being pressed
  • Velocity refers to how hard the key is played
Here the timestamp uses hexadecimal representation that is how the "note" 60 is represented as 3C in the timestamp in your code.
Refer the following document for more information
Hope this helps!
  댓글 수: 1
David Koenig
David Koenig 2019년 8월 1일
Thanks Samantha but that material is not new.
The first key to solving my problem dealt with hooking the "in" probe to the "out" connection and not the other way around (which I was doing). The second key was my stumbling onto the codes in the P120 manual for the program change message, i.e., using the program change message with the appropriate code allows me to send key strike commands to instruments other than the default grand piano.
So, thanks, Samantha for taking the time to try to answer my question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by