Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Singing Digital Camera (Nakayoshi Camera + Pocket mike)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pygame
import pygame.midi
from time import sleep
import picamera
instrument = 0 # miku
port = 2 # NSX-39
pygame.init()
pygame.midi.init()
for id in range(pygame.midi.get_count()):
print id
print pygame.midi.get_device_info(id)
midiOutput = pygame.midi.Output(port)
midiOutput.set_instrument(instrument)
# setting lyric by sending SysEx
midiOutput.write_sys_ex(pygame.midi.time(), [0xF0, 0x43, 0X79, 0x09, 0x11, 0x0A, 0x00, 0x4A, 0x7B, 0x31, 0x25, 0x08, 0x7B, 0x10, 0x02, 0x28, 0xF7])
midiOutput.note_on(74, 80)
sleep(.400)
midiOutput.note_on(74, 80)
sleep(.100)
midiOutput.note_on(74, 80)
sleep(.400)
midiOutput.note_on(74, 80)
sleep(.100)
midiOutput.note_on(74, 80)
sleep(.400)
midiOutput.note_on(74, 80)
sleep(.100)
midiOutput.note_on(74, 80)
sleep(.400)
midiOutput.note_on(74, 80)
sleep(.100)
midiOutput.note_on(79,80)
sleep(.200)
midiOutput.note_off(79,80)
with picamera.PiCamera() as camera:
camera.resolution = (1024,768)
camera.start_preview()
sleep(1.000)
camera.capture('mikucamera.jpg')
del midiOutput
pygame.midi.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment