Changeset e8d0c06


Ignore:
Timestamp:
Feb 15, 2006, 11:31:46 AM (18 years ago)
Author:
Paul Brossier <piem@altern.org>
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
Message:

updated audacity plugin
updated audacity plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/audacity/plug-ins/aubioonset.ny

    rada5baf re8d0c06  
    55;action "Generate onset label track using aubioonset..."
    66;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)
    828
    929; largest number of samples
    1030(setf largenumber 1000000000)
     31
    1132; 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
    1438; 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))
    1746
    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")
     47; save current sound selection into mono infile
     48(s-save (mono-s s) (snd-length (mono-s s) largenumber) infile)
     49
    2150; run aubio
    2251(system aubiocmd)
     
    2453; read the file and build the list of label in result
    2554(let* (
    26         (fp (open "/tmp/test.txt" :direction :input))
    27         (result '())
    28         (n 1)
    29         (c (read-line fp))
     55        (fp (open tmfile :direction :input))
     56        (result '())
     57        (n 1)
     58        (c (read-line fp))
    3059      )
    3160 (read-line fp)
     61 
     62 ;(setf oldc c)
    3263 (while (not (not c))
    3364   (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)
    3871   (setf c (read-line fp))
    3972   (setq n (+ n 1))
    4073  )
    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.