Jump to content

Recommended Posts

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

Posted

example please, how the data should look like.

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; ...

 

output:

?

Posted
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 ...

Posted

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;"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy