forked from mirrors/gecko-dev
		
	 ee6325f662
			
		
	
	
		ee6325f662
		
	
	
	
	
		
			
			This is as close to usptream as currently possibly. Only a few changes were done to the dependencies: the wasm target was removed and the coremidi dependency was updated to pick up a more recent version so that we don't need to vendor separate versions of the core-foundation and core-foundation-sys crates. This vendors the following crates: * alsa-sys * alsa * coremidi * coremidi-sys * memalloc * midir Overall this adds ~30K lines of code, over half of which is in the alsa bindings alone. Differential Revision: https://phabricator.services.mozilla.com/D124640
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			928 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			928 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| extern crate coremidi;
 | |
| 
 | |
| use std::thread;
 | |
| use std::time::Duration;
 | |
| 
 | |
| fn main() {
 | |
|     let client = coremidi::Client::new("Example Client").unwrap();
 | |
|     let source = client.virtual_source("Example Source").unwrap();
 | |
| 
 | |
|     let note_on = create_note_on(0, 64, 127);
 | |
|     let note_off = create_note_off(0, 64, 127);
 | |
| 
 | |
|     for i in 0..10 {
 | |
|         println!("[{}] Sending note...", i);
 | |
| 
 | |
|         source.received(¬e_on).unwrap();
 | |
| 
 | |
|         thread::sleep(Duration::from_millis(1000));
 | |
| 
 | |
|         source.received(¬e_off).unwrap();
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn create_note_on(channel: u8, note: u8, velocity: u8) -> coremidi::PacketBuffer {
 | |
|     let data = &[0x90 | (channel & 0x0f), note & 0x7f, velocity & 0x7f];
 | |
|     coremidi::PacketBuffer::new(0, data)
 | |
| }
 | |
| 
 | |
| fn create_note_off(channel: u8, note: u8, velocity: u8) -> coremidi::PacketBuffer {
 | |
|     let data = &[0x80 | (channel & 0x0f), note & 0x7f, velocity & 0x7f];
 | |
|     coremidi::PacketBuffer::new(0, data)
 | |
| }
 |