Jump to content

Featured Replies

Posted

Does anybody have an idea, how to loop through a directory and writing the content of a textfile (like the one attached) without the semicolons into normal lists?

Thanks for help.

Achimch1-amp-envs.txt

  • Author
0 1-amp-env 1 11000; 11000 1-amp-env 1 6000; 6000 1-amp-env 0.2 10000; 10000 1-amp-env 1 5000

should change to

0 1-amp-env 1 22000; 22000 1-amp-env 1 12000; 12000 1-amp-env 0.2 20000; 20000 1-amp-env 1 10000

These are sequencer files from Puredata in which I'd like to change the timestamps in msecs to double time.

Input is a txt document and the output should be a txt document as well.

The reason for this approach is that I have quite a few of this files to change ...

The file contents need to be a string.

 

(defun remove-semicolon (string)
  (remove ";" string :test #'string=))

(setf orig "0 1-amp-env 1 11000; 11000 1-amp-env 1 6000; 6000 1-amp-env 0.2 10000; 10000 1-amp-env 1 5000;")
(setf pd1 (string-to-list (remove-semicolon orig)))
(setf pd2 (gen-divide 4 pd1))
(setf pd3 (loop for i in pd2 collect (list (* 2 (1~ i)) (2~ i) (3~ i) (* 2 (4~ i)))))

(join-string-list
 (loop for i in pd3
       collect (string-replace " ;" ";" (join-string-list (list (list-to-string i) ";")))))
=> "0 1-amp-env 1 22000; 22000 1-amp-env 1 12000; 12000 1-amp-env 0.2 20000; 20000 1-amp-env 1 10000;"
  • Author

That looks really good. Thanks a lot. Achim

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy