import 0.1.7.1
[aubio.git] / plugins / audacity / plug-ins / aubioonset.ny
1 ;nyquist plug-in
2 ;version 1
3 ;type analyze
4 ;name "Onset Detection..."
5 ;action "Generate onset label track using aubioonset..."
6 ;info "Aubio onset detector:\n Generates a label track with markers at the beginning of audio events"
7 ;control threshold "Detection threshold" real "[0.001-0.900...]" 0.1 0.001 1.0
8
9 ; largest number of samples 
10 (setf largenumber 1000000000) 
11 ; some temporary files
12 (setf infile "/tmp/test.wav")
13 (setf tmfile "/tmp/test.txt")
14 ; our command lines
15 (setf aubiocmd (strcat "aubioonset -t " (ftoa threshold) " -i " infile " > " tmfile))
16 (setf deletcmd "rm -f /tmp/test.wav /tmp/test.txt")
17
18 ; save current selection in /tmp
19 ; bug: should check the sound is mono
20 (s-save s (snd-length s largenumber) "/tmp/test.wav")
21 ; run aubio
22 (system aubiocmd)
23
24 ; read the file and build the list of label in result
25 (let* (
26         (fp (open "/tmp/test.txt"  :direction :input))
27         (result '())
28         (n 1)
29         (c (read-line fp))
30       )
31  (read-line fp)
32  (while (not (not c))
33    (setq result 
34         (append
35         result
36         (list (list (atof c) ""))
37         ))
38    (setf c (read-line fp))
39    (setq n (+ n 1))
40   )
41 (close fp)
42 (system deletcmd)
43 ;uncomment to debug
44 ;(print result) 
45 result)