Last active
August 29, 2015 14:01
-
-
Save pklazy/31186b2bd1cc2c3555b4 to your computer and use it in GitHub Desktop.
NSX-39 테스트
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import pygame.midi as pm | |
import time | |
if __name__ == '__main__': | |
pm.init() | |
mo = None | |
mi = None | |
for i in range(pm.get_count()): | |
interf, name, input, output, opened = pm.get_device_info(i) | |
if name[:6] != 'NSX-39': continue | |
if output == 1: mo = pm.Output(i) | |
if input == 1: mi = pm.Input(i) | |
if mo != None and mi != None: break | |
if mo == None: | |
pm.quit() | |
quit() | |
if mi == None: | |
pm.quit() | |
quit() | |
# 출력 음성을 '아'로 변경 | |
mo.write_sys_ex(0, [0xf0, 0x43, 0x79, 0x09, 0x11, 0x0a, 0x00, 0x00, 0xf7]) | |
# key를 변경하여 '도레미'를 만듬 | |
# C5 | |
mo.write_short(0x90, 72, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 72 ) | |
time.sleep(0.1) | |
# D5 | |
mo.write_short(0x90, 74, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 74 ) | |
time.sleep(0.1) | |
# E5 | |
mo.write_short(0x90, 76, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 76 ) | |
time.sleep(0.1) | |
# Pich bend를 변경하여 '도레미'를 만듬 | |
# C5 | |
mo.write_short(0xe0, 0, 40 ) | |
mo.write_short(0x90, 78, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 78 ) | |
time.sleep(0.1) | |
# D5 | |
mo.write_short(0xe0, 0, 48 ) | |
mo.write_short(0x90, 78, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 78 ) | |
time.sleep(0.1) | |
# E5 | |
mo.write_short(0xe0, 0, 56 ) | |
mo.write_short(0x90, 78, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 78 ) | |
time.sleep(0.1) | |
# default pitch bend | |
mo.write_short(0xe0, 0x00, 0x40 ) | |
# Modulation test | |
mo.write_short(0xb0, 0x01, 0x7f ) | |
mo.write_short(0x90, 72, 99 ) | |
time.sleep(1) | |
mo.write_short(0x80, 72 ) | |
time.sleep(0.1) | |
mo.write_short(0xb0, 0x01, 0x00 ) | |
mo.close() | |
mi.close() | |
pm.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment