alsa-seq-tests (empty) → 0.1
raw patch · 8 files changed
+191/−0 lines, 8 filesdep +alsadep +basesetup-changed
Dependencies added: alsa, base
Files
- LICENSE +7/−0
- Setup.lhs +8/−0
- alsa-seq-tests.cabal +31/−0
- test1.hs +25/−0
- test2.hs +35/−0
- test3.hs +33/−0
- test4.hs +11/−0
- test5.hs +41/−0
+ LICENSE view
@@ -0,0 +1,7 @@+Copyright (c) 2006 Iavor S. Diatchki++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.lhs view
@@ -0,0 +1,8 @@+#!/usr/bin/env runghc++> module Main where++> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ alsa-seq-tests.cabal view
@@ -0,0 +1,31 @@+Name: alsa-seq-tests+License: BSD3+License-file: LICENSE+Version: 0.1+Author: Iavor S. Diatchki+Maintainer: iavor.diatchki@gmail.com+Category: Sound, Music+Synopsis: Tests for the ALSA sequencer library.+Description: Tests for the ALSA sequencer library.+Build-type: Simple+Cabal-Version: >= 1.2++Executable test1+ main-is: test1.hs+ Build-Depends: base >=3, alsa == 0.2++Executable test2+ main-is: test2.hs+ Build-Depends: base >=3, alsa == 0.2++Executable test3+ main-is: test3.hs+ Build-Depends: base >=3, alsa == 0.2++Executable test4+ main-is: test4.hs+ Build-Depends: base >=3, alsa == 0.2++Executable test5+ main-is: test5.hs+ Build-Depends: base >=3, alsa == 0.2
+ test1.hs view
@@ -0,0 +1,25 @@+import Sound.Alsa.Sequencer++main :: IO ()+main =+ do putStrLn "Starting."+ h <- open default_seq_name open_input Block+ set_client_name h "HS1"+ putStrLn "Created sequencer."+ p1 <- create_simple_port h "one"+ (caps [cap_write,cap_subs_write]) type_midi_generic++ p2 <- create_simple_port h "two"+ (caps [cap_write,cap_subs_write]) type_midi_generic+ putStrLn "Created ports."+ let loop = do putStrLn "waiting for an event:"+ e <- event_input h+ print e+ loop+ loop+ delete_port h p1+ delete_port h p2+ putStrLn "Deleted ports."+ close h+ putStrLn "Closed sequencer."+ `alsa_catch` \e -> putStrLn ("Problem: " ++ exception_description e)
+ test2.hs view
@@ -0,0 +1,35 @@+import Sound.Alsa.Sequencer++main :: IO ()+main =+ do putStrLn "Starting."+ h <- open default_seq_name open_output Block+ set_client_name h "HS test client"+ putStrLn "Created sequencer."+ p <- create_simple_port h "one"+ (caps [cap_read,cap_subs_read]) type_midi_generic+ putStrLn "Created port."+ x <- get_client_id h+ putStrLn ("My id is: " ++ show x)+ let me = Addr { addr_client = x, addr_port = p }+ getChar+ event_output_direct h (e1 me)+ getChar+ delete_port h p+ putStrLn "Deleted port."+ close h+ putStrLn "Closed sequencer."+ `alsa_catch` \e -> putStrLn ("Problem: " ++ exception_description e)+++++e1 me = Event+ { ev_high_priority = False+ , ev_tag = 0+ , ev_queue = queue_direct+ , ev_timestamp = TickTime 0+ , ev_source = me+ , ev_dest = addr_subscribers+ , ev_data = NoteEv NoteOn (simple_note 0 60 100)+ }
+ test3.hs view
@@ -0,0 +1,33 @@+import Sound.Alsa.Sequencer++main :: IO ()+main =+ do putStrLn "Starting."+ h <- open default_seq_name open_output Block+ set_client_name h "HS3"+ putStrLn "Created sequencer."+ x <- get_client_id h+ putStrLn ("My id is: " ++ show x)+ let me = Addr { addr_client = x, addr_port = port_unknown }+ -- tgt_addr <- parse_address h "HS1:255"+ let tgt_addr = Addr client_broadcast port_unknown+ print tgt_addr+ getChar+ event_output_direct h (e1 me tgt_addr)+ getChar+ close h+ putStrLn "Closed sequencer."+ `alsa_catch` \e -> putStrLn ("Problem: " ++ exception_description e)+++++e1 from to = Event+ { ev_high_priority = False+ , ev_tag = 0+ , ev_queue = queue_direct+ , ev_timestamp = TickTime 0+ , ev_source = from+ , ev_dest = to+ , ev_data = NoteEv NoteOn (simple_note 0 60 100)+ }
+ test4.hs view
@@ -0,0 +1,11 @@+import Sound.Alsa.Sequencer+import Control.Monad(when)++main = do h <- open default_seq_name open_output Block+ i <- query_first_client h+ let loop = do putStrLn =<< client_info_get_name i+ more <- query_next_client h i+ when more loop+ loop+ close h+
+ test5.hs view
@@ -0,0 +1,41 @@+import Sound.Alsa.Sequencer++main = do h <- open default_seq_name open_output Block+ set_client_name h "HS5"+ p <- create_simple_port h "1" (caps [cap_read,cap_subs_read])+ type_midi_generic+ c <- get_client_id h+ q <- alloc_queue h+ let ev t e = Event+ { ev_high_priority = False+ , ev_tag = 0+ , ev_queue = q+ , ev_timestamp = TickTime t+ , ev_source = Addr { addr_client = c, addr_port = p }+ , ev_dest = addr_subscribers+ , ev_data = e+ }+ play t x y z =+ do print =<< event_output h (ev 0 $ NoteEv NoteOn+ $ simple_note x y z)++ print =<< event_output h (ev t $ NoteEv NoteOn+ $ simple_note x y 0)+ putStrLn "Please connect me to a synth"+ getChar+ play 4 0 60 127+ drain_output h+ print =<< event_output_pending h++ free_queue h q+ delete_port h p+ close h++ `alsa_catch` \e -> putStrLn $ "alsa_exception: (" ++ show (exception_code e)+ ++ ") " ++ exception_description e++++++