erka Posted February 3, 2023 Share Posted February 3, 2023 With length-modify it seems that I can either modify notes or rests or random. length-modify.pdf: type 'r (rest) or 'n (note) or '? (at random), if not specified random type is used. Wouldn't :type 'all also be useful? I could use it for what I am doing now. Now I realized it by calling :type 'n and :type 'r one after the other. Is there another function that would modify all (rest and notes)? Quote Link to comment Share on other sites More sharing options...
opmo Posted February 3, 2023 Share Posted February 3, 2023 What are you trying to do (code example input, output). What 'all will do? Quote Link to comment Share on other sites More sharing options...
erka Posted February 3, 2023 Author Share Posted February 3, 2023 The function takes a string as input and returns the omn . Auditioning it will sound like a morse message. Setting :morse_output to t will output the real morse-message (for testing ..). You can input any :pitch and the morsecode loops over the :pitch or just change the pitch of the output What I was looking for is way to change the basic unit. This is set in the map to s (1/16). It is Between ;; make changes for non-default units and ;; prepare for morse output. (defun text-to-morse-omn (text &key ( pitch 'c4 ) ( dit_length 1/16 ) (morse_output nil)) "converting text -> morse -> omn-length reference: wikipedia default time unit is 1/16. International Morse code is composed of five elements: short mark, dot or dit ( ▄ is one time unit long long mark, dash or dah ( ▄▄▄ three time units long inter-element gap between the dits and dahs within a character: one dot duration or one unit long short gap (between letters): three time units long medium gap (between words): seven time units long " (if (or (stringp text) (stringp (car text))) () (return-from text-to-morse-omn "text must be string or string in list")) (let* ( ( char_lengths_map ;; includes the dit between the dits and dahs ;; and the 3 dits for end of letter '( ( a ((s -s s== -s==)) ) ( b ((s== -s s -s s -s s -s==)) ) ( c ((s== -s s -s s== -s s -s==)) ) ( d ((s== -s s -s s -s==)) ) ( e ((s -s==)) ) ( f ((s -s s -s s== -s s -s==)) ) ( g ((s== -s s== -s s -s==)) ) ( h ((s -s s -s s -s s -s==)) ) ( i ((s -s s -s==)) ) ( j ((s -s s== -s s== -s s== -s==)) ) ( k ((s== -s s -s s== -s==)) ) ( l ((s -s s== -s s -s s -s==)) ) ( m ((s== -s s== -s==)) ) ( n ((s== -s s -s==)) ) ( o ((s== -s s== -s s== -s==)) ) ( p ((s -s s= -s= s== -s s -s==)) ) ( q ((s== -s s== -s s -s s== -s==)) ) ( r ((s -s s== -s s -s==)) ) ( s ((s -s s -s s -s==)) ) ( t ((s== -s==)) ) ( u ((s -s s -s s== -s==)) ) ( v ((s -s s -s s -s s== -s==)) ) ( w ((s -s s== -s s== -s==)) ) ( x ((s== -s s -s s -s s== -s==)) ) ( y ((s== -s s -s s== -s s== -s==)) ) ( z ((s== -s s== -s s -s s -s==)) ) ( 1 ((s -s s== -s s== -s s== -s s== -s==)) ) ( 2 ((s -s s -s s== -s s== -s s== -s==)) ) ( 3 ((s -s s -s s -s s= -s= s== -s==)) ) ( 4 ((s -s s -s s -s s -s s== -s==)) ) ( 5 ((s -s s -s s -s s -s s -s==)) ) ( 6 ((s== -s s -s s -s s -s s -s==)) ) ( 7 ((s== -s s== -s s -s s -s s -s==)) ) ( 8 ((s== -s s== -s s== -s s -s s -s==)) ) ( 9 ((s== -s s== -s s== -s s== -s s -s==)) ) ( 0 ((s== -s s== -s s== -s s== -s s== -s==)) ) ( ä ((s -s s== -s s -s s== -s==)) ) ( ö ((s== -s s== -s s== -s s -s==)) ) ( ü ((s -s s -s s== -s s== -s==)) ) ( ß ((s -s s -s s -s s -s s -s s -s==))) ; french letters can be easier added with a french keyboard ; punctuation is ignored by text-map and this function )) ( mapstr (text-map char_lengths_map text)) ;; remove last rest from letter ;; to add 7 dits later ( removelastrests (if (not (listp (car mapstr)) ) ; if only one word (list ( butlast mapstr 1)) (loop for i in mapstr collect (butlast i 1)))) ;; add 7 dits for end of word. Needed for decoding into real morse maybe later ( add7 (loop for x in removelastrests collect (append x '(-s======)))) ;; make omnstr ( default_omnstr (make-omn :length add7 :pitch (list pitch) :span :length)) ;; make changes for non-default units ( s_unit 1/16) ; default for 's ( u_unit dit_length) ;user set unit ( oper (if (>= s_unit u_unit) 'times 'divide)) ( mult (if (equalp oper 'divide) (/ s_unit u_unit) (/ u_unit s_unit))) ( mod_notes (length-modify mult default_omnstr :type 'n :operator oper :count 'all)). ;first run of length-modify for notes ( dit_modified_omn (length-modify mult mod_notes :type 'r :operator oper :count 'all)) ; another run for rests ;; prepare for morse output ( omn_morse_map '(( s "." ) ( s== "-" ) ( -s== " " ) ( -s====== " / "))) ( mapstr (text-map omn_morse_map default_omnstr)) ( morsestr (loop for i in mapstr collect (eval (cons 'concatenate (cons ''string i))))) ) ; end of variablelist ;; decide output due to :morse_output t or nil (if morse_output (format T "~a" morsestr) dit_modified_omn) ) ; end let* ) (setf ttmo_ret (text-to-morse-omn "bla" :pitch 'c3 :morse_output nil) ) => ((e. c3 -s c3 - c3 - c3 -e. s c3 - e. c3 -s c3 - c3 -e. s c3 - e. c3 -q..)) -------------- My first function I am writing in opusmodus and lisp. I learned a lot doing it. That was the main purpose. And maybe make strange music with it. Maybe some morse-trained person will get the message. I had something similar written for max-for-live mainly in javascript to learn all the functions needed to put notes into a clip. And had some musical fun with it. Quote Link to comment Share on other sites More sharing options...
erka Posted February 3, 2023 Author Share Posted February 3, 2023 another question for this function: How could I convert a symbol input ('e) to :dit_length input into a ratio for later calculation? A conversion from length symbol to ratio. Quote Link to comment Share on other sites More sharing options...
o_e Posted February 3, 2023 Share Posted February 3, 2023 hth morse.opmo morse.rtfd.zip Quote Link to comment Share on other sites More sharing options...
erka Posted February 3, 2023 Author Share Posted February 3, 2023 Thank you o-e. That is much better. You didn't write this including doc this afternoon, did you? length-diminution and text-to-letters I didn't know. I learned a lot by going the complicated way. Do you know how to convert an input of length-symbol to ratio? In your function I think length-diminution is handling this. You can set :pulse 's . Quote Link to comment Share on other sites More sharing options...
opmo Posted February 3, 2023 Share Posted February 3, 2023 (encode-seq '(w q e -e = =)) => (1 1/4 1/8 -1/8 1/8 1/8) Quote Link to comment Share on other sites More sharing options...
erka Posted February 3, 2023 Author Share Posted February 3, 2023 (encode-seq 't) => t (encode-seq (list 't)) => (1/32) When the user inputs in my example :dit_length 't ,I would write (car (encode-seq (list :dit_length))) => 1/32 to get a value for calculation. Quote Link to comment Share on other sites More sharing options...
opmo Posted February 3, 2023 Share Posted February 3, 2023 alternative: length-to-ratio Quote Link to comment Share on other sites More sharing options...
erka Posted February 4, 2023 Author Share Posted February 4, 2023 That is what I was looking for. It doesn't show up on a search, but can be used. Quote Link to comment Share on other sites More sharing options...
erka Posted February 5, 2023 Author Share Posted February 5, 2023 I rewrote the function, so I can enter any length-symbol or ratio and don't have to make complicated calculations. Looks good to me and does what I wanted. I don't use length-modify anymore. But still wonder way 'all is not a feature. If you have any suggestions regarding style or other optimization please let me know. I had entered this forum in 2015 but was into other things until release of v3. In case you are wondering. Just starting again with lisp and opusmodus. I made a short score and my wife smiled while listening. text2morse-length.opmo jon, AM and Stephane Boussuge 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.