Changeset e8d0c06
- Timestamp:
- Feb 15, 2006, 11:31:46 AM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- d9101a5
- Parents:
- ada5baf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/audacity/plug-ins/aubioonset.ny
rada5baf re8d0c06 5 5 ;action "Generate onset label track using aubioonset..." 6 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 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 ) 8 28 9 29 ; largest number of samples 10 30 (setf largenumber 1000000000) 31 11 32 ; some temporary files 12 (setf infile "/tmp/test.wav") 13 (setf tmfile "/tmp/test.txt") 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 14 38 ; 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") 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)) 17 46 18 ; save current s election in /tmp19 ; bug: should check the sound is mono 20 (s-save s (snd-length s largenumber) "/tmp/test.wav") 47 ; save current sound selection into mono infile 48 (s-save (mono-s s) (snd-length (mono-s s) largenumber) infile) 49 21 50 ; run aubio 22 51 (system aubiocmd) … … 24 53 ; read the file and build the list of label in result 25 54 (let* ( 26 (fp (open "/tmp/test.txt":direction :input))27 28 29 55 (fp (open tmfile :direction :input)) 56 (result '()) 57 (n 1) 58 (c (read-line fp)) 30 59 ) 31 60 (read-line fp) 61 62 ;(setf oldc c) 32 63 (while (not (not c)) 33 64 (setq result 34 (append 35 result 36 (list (list (atof c) "")) 37 )) 65 (append 66 result 67 ;(list (list (strcat oldc " " c) "")) 68 (list (list (atof c) "")) 69 )) 70 ;(setf oldc c) 38 71 (setf c (read-line fp)) 39 72 (setq n (+ n 1)) 40 73 ) 41 (close fp) 42 (system deletcmd) 43 ;uncomment to debug 44 ;(print result) 45 result) 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 TracChangeset
for help on using the changeset viewer.