source: plugins/audacity/plug-ins/aubioonset.ny @ 67d0a8b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 67d0a8b was e8d0c06, checked in by Paul Brossier <piem@altern.org>, 18 years ago

updated audacity plugin
updated audacity plugin

  • Property mode set to 100644
File size: 2.2 KB
Line 
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 dmode "Detection Beats/Onsets" int "0=Beats 1=Onsets" 1 0 1
8;control threshold "Detection threshold" real "[0.001-0.900...]" 0.3 0.001 1.0
9;control omode "Mode" int "0=ComplexDomain 1=HFC 2=Specdiff 3=Phase 4=Energy" 0 0 3
10
11;Create a function to make the sum the two channels if they are stereo
12(defun mono-s (s-in)
13  (if (arrayp s-in) (snd-add (aref s-in 0) (aref s-in 1)) s-in)
14)
15
16; path to aubio commands
17(cond
18  ((= dmode 0)(setf aubiocmd "/home/piem/aubio/aubio/examples/aubiotrack"))
19  (t (setf aubiocmd "/home/piem/aubio/aubio/examples/aubioonset"))
20)
21
22(cond
23  ((= omode 0)(setf onsetmode "complexdomain"))
24  ((= omode 1)(setf onsetmode "hfc"))
25  ((= omode 2)(setf onsetmode "specdiff"))
26  (t (setf onsetmode "dual"))
27)
28
29; largest number of samples
30(setf largenumber 1000000000)
31
32; some temporary files
33;(setf infile (system "mktmp tmp-aubio-XXXXXX"))
34;(setf tmfile (system "mktmp tmp-aubio-XXXXXX"))
35(setf infile "/tmp/aubio-insecure.wav")
36(setf tmfile "/tmp/aubio-insecure.txt")
37
38; our command lines
39(setf aubiocmd (strcat
40        aubiocmd
41        " -O " onsetmode
42        " -t " (ftoa threshold)
43        " -i " infile
44        " > "  tmfile))
45(setf deletcmd (strcat "rm -f " infile " " tmfile))
46
47; save current sound selection into mono infile
48(s-save (mono-s s) (snd-length (mono-s s) largenumber) infile)
49
50; run aubio
51(system aubiocmd)
52
53; read the file and build the list of label in result
54(let* (
55        (fp (open tmfile :direction :input))
56        (result '())
57        (n 1)
58        (c (read-line fp))
59      )
60 (read-line fp)
61 
62 ;(setf oldc c)
63 (while (not (not c))
64   (setq result
65        (append
66        result
67        ;(list (list (strcat oldc "     " c) ""))
68        (list (list (atof c) ""))
69        ))
70   ;(setf oldc c)
71   (setf c (read-line fp))
72   (setq n (+ n 1))
73  )
74  (close fp)
75
76  (system deletcmd)
77
78  ;uncomment to debug
79  ;(print result)
80
81
82  ;If no silence markers were found, return a message
83  (if (null result)
84   (setq result "No onsets or beats found, no passages marked")
85  )
86 
87  result
88
89)
90
Note: See TracBrowser for help on using the repository browser.