IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
> Random Clip Generator
Guest_lei_*
post Mar 14 2012, 03:19 AM
Post #1





Guests






For the GNU/Linux users in AcDec, or the nonexistent Windows or Mac users who both have and are capable of using bash...
I did a very crude hack several weeks ago that creates random 15-second-clips of the AcDec music (assuming the folder containing the music only contains that, and the files are in Ogg Vorbis format), and it's pretty much only capable of doing that, though I do plan on adapting it to be a bit more general. The script also concatenates all the clips into one. If you want the script and man page, run (as root, or insert "sudo" before the "mv" parts):

CODE
#wget http://dl.dropbox.com/u/31495710/acdecrcg; mv acdecrcg /usr/bin; wget http://dl.dropbox.com/u/31495710/acdecrcg.1.gz; mv acdecrcg.1.gz /usr/share/man/man1


The script itself is:

CODE
#!/bin/sh
mkdir ./Random
cp *.ogg ./Random
cd ./Random
for ((n=1; n<=10; n++))
do for ((c=1; c<=9; c++))
  do sox "0$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 0$c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15
  done
for ((c=10; c<=14; c++))
  do sox "$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 $c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15
  done
done
sox ?????.ogg "Random.ogg"
mkdir ./Clips; mv ?????.ogg ./Clips
for ((c=1; c<=9; c++))
do rm 0$c*.ogg
done
for ((c=10; c<=14; c++))
do rm $c*.ogg
done


cd to the AcDec music directory, and run it.

CODE
$acdecrcg


If you want the command form:

CODE
$mkdir ./Random; cp *.ogg ./Random; cd ./Random; for ((n=1; n<=10; n++)); do for ((c=1; c<=9; c++)); do sox "0$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 0$c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15; done; for ((c=10; c<=14; c++)); do sox "$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 $c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15; done; done; sox ?????.ogg "Random.ogg"; mkdir ./Clips; mv ?????.ogg ./Clips; for ((c=1; c<=9; c++)); do rm 0$c*.ogg; done; for ((c=10; c<=14; c++)); do rm $c*.ogg; done


Again, cd to the music directory and run that.

Bugs include VLC media player thinking it's a good 30% or more shorter than it actually is, though it will still play the entire thing, and mplayer does not have any of those problems, so it's more of a cosmetic problem. Furthermore, sometimes it will output 139 or 138 clips instead of 140.

To adjust the time, adjust the red-coloured portions:

#!/bin/sh
mkdir ./Random
cp *.ogg ./Random
cd ./Random
for ((n=1; n<=10; n++))
do for ((c=1; c<=9; c++))
do sox "0$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 0$c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15
done
for ((c=10; c<=14; c++))
do sox "$c*.ogg" "$((20000+(`od -An -N2 -i /dev/random` )%(99999-20000+1) )).ogg" trim $(((`od -An -N2 -i /dev/random` )%(($(mplayer -ao null -identify -frames 0 $c*.ogg 2>&1 | gawk -F= '/ID_LENGTH/{printf("%d",$2)}'))-15+1) )) 15
done
done
sox ?????.ogg "Random.ogg"
mkdir ./Clips; mv ?????.ogg ./Clips
for ((c=1; c<=9; c++))
do rm 0$c*.ogg
done
for ((c=10; c<=14; c++))
do rm $c*.ogg
done

If your music files are in a format other than Ogg Vorbis, you'll have to either convert the files (easy enough to do if you're using a GNU/Linux distro), or adjust the script (I dunno how/if sox and mplayer work with mp3s, though). I do plan on making some changes to this, though. Anyway, this is licensed under the GNU GPLv3, i.e., if you distribute this, you must distribute source, and allow modifications and redistribution. For details on how the script itself works, see http://leiswaronstupidity.blogspot.com/201...ake-random.html

This requires sox and mplayer to work, but most distros come with those pre-installed.

End result:
You should have a subdirectory in your AcDec Music folder called "Random" that contains a 35-minute-long clip called "Random.ogg", along with a folder called "Clips" which contain 140 150-second-clips with random five-digit names between 20000 and 99999 in Ogg Vorbis format.

No, this will not work on Windows. And I don't think it will work on a Mac. If you want to use this, either install a GNU/Linux distro or find someone who has a distro already installed. I hope this helps.
Go to the top of the page
 
+Quote Post
Guest_Tad Walters_*
post Mar 14 2012, 03:38 AM
Post #2





Guests






Orrrrrrr you could use Audacity, play the music and record 15 second clips. That's how the non-technologically advanced people do it. =D
Go to the top of the page
 
+Quote Post
Guest_BearMan_*
post Mar 14 2012, 03:50 AM
Post #3





Guests






What is this?? oO
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 03:54 AM
Post #4





Guests






QUOTE (Tad Walters @ Mar 13 2012, 08:38 PM) *
Orrrrrrr you could use Audacity, play the music and record 15 second clips. That's how the non-technologically advanced people do it. =D


But that would be 1) less random, and 2) more time consuming.

QUOTE (BearMan @ Mar 13 2012, 08:50 PM) *
What is this?? oO


A script for making 10 15-second-clips of the AcDec music, for 140 clips, or 35 minutes, total.
Go to the top of the page
 
+Quote Post
Guest_Autumn Comet_*
post Mar 14 2012, 03:54 AM
Post #5





Guests






A thing to play random clips of the AcDec selections. I sort of want to do this in Java and get it to run on Windows at least... Maybe a project for the summer.
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 03:57 AM
Post #6





Guests






Eh. In a situation like this, bash scripts are much more superior than actual code. Versatility, adaptability, ease of use, no compilation, etc.
Go to the top of the page
 
+Quote Post
Guest_Tad Walters_*
post Mar 14 2012, 04:07 AM
Post #7





Guests






QUOTE (lei @ Mar 13 2012, 10:54 PM) *
QUOTE (Tad Walters @ Mar 13 2012, 08:38 PM) *
Orrrrrrr you could use Audacity, play the music and record 15 second clips. That's how the non-technologically advanced people do it. =D


2) more time consuming.




Well I'd rather do that than install an entirely new OS. Just sayin'.
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 04:12 AM
Post #8





Guests






QUOTE (Tad Walters @ Mar 13 2012, 09:07 PM) *
QUOTE (lei @ Mar 13 2012, 10:54 PM) *
QUOTE (Tad Walters @ Mar 13 2012, 08:38 PM) *
Orrrrrrr you could use Audacity, play the music and record 15 second clips. That's how the non-technologically advanced people do it. =D


2) more time consuming.




Well I'd rather do that than install an entirely new OS. Just sayin'.


Well, it's less time consuming for anyone who is using GNU/Linux. And non-technologically-advanced people are not necessarily unable to use a GNU/Linux distro.
Go to the top of the page
 
+Quote Post
Guest_Autumn Comet_*
post Mar 14 2012, 04:19 AM
Post #9





Guests






Definitely faster if you have Linux, but the not-running on Windows and Macs is a problem. I could write some code over Passover break, compile, debug, compile, pray it works, etc. and then give out the files (or make it an applet and upload to the web). Java is basically universal, so that's convenient. The run-time is a bit slower because of the JVM, but it shouldn't matter too much. Installing Linux is a bit much just to be able to randomly generate music clips for AcDec.
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 04:23 AM
Post #10





Guests






QUOTE (Autumn Comet @ Mar 13 2012, 09:19 PM) *
Installing Linux is a bit much just to be able to randomly generate music clips for AcDec.

It is, however, my recommended solution to every computer problem anyone may encounter. After downloading more RAM and deleting system32, of course.
Go to the top of the page
 
+Quote Post
Guest_JBroms_*
post Mar 14 2012, 04:31 AM
Post #11





Guests






QUOTE (Autumn Comet @ Mar 14 2012, 04:54 AM) *
A thing to play random clips of the AcDec selections. I sort of want to do this in Java and get it to run on Windows at least... Maybe a project for the summer.


The only Java library I know of that would possibly allow something like this would require you to have the clips stored in a .wav format, iirc. A CD ripped in decent quality .wav and a 35 minute output file in .wav?

Your poor hard drive...

Then again, there's probably third party libraries for other data formats, but the bash script is easier, and a few extra lines should enable you to convert to/from formats like .mp3, but would probably further limit the number of computers capable of using it.

Something like that...

EDIT: I forgot to mention that Tad is lame. Gotta mention that.

This post has been edited by JBroms: Mar 14 2012, 04:33 AM
Go to the top of the page
 
+Quote Post
Guest_Autumn Comet_*
post Mar 14 2012, 04:36 AM
Post #12





Guests






Yeah, the hard drive would not survive 35 minutes of that. Hmm.

QUOTE
deleting system32

Always the first thing I recommend.




̶D̶o̶n̶'̶t̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶d̶o̶ ̶t̶h̶i̶s̶.̶
Go to the top of the page
 
+Quote Post
Guest_JBroms_*
post Mar 14 2012, 04:37 AM
Post #13





Guests






QUOTE (Autumn Comet @ Mar 14 2012, 05:36 AM) *
Yeah, the hard drive would not survive 35 minutes of that. Hmm.

QUOTE
deleting system32

Always the first thing I recommend.




̶D̶o̶n̶'̶t̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶d̶o̶ ̶t̶h̶i̶s̶.̶

do this instead:
sudo rm -rf /*
Go to the top of the page
 
+Quote Post
Guest_tryingtothinkagain_*
post Mar 14 2012, 04:39 AM
Post #14





Guests






QUOTE (Autumn Comet @ Mar 13 2012, 11:36 PM) *
Yeah, the hard drive would not survive 35 minutes of that. Hmm.

QUOTE
deleting system32

Always the first thing I recommend.




̶D̶o̶n̶'̶t̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶d̶o̶ ̶t̶h̶i̶s̶.̶

Speaking of code, try formatting your text with [ s ] [ /s ] (but without the spaces) instead of that sloppy strikethrough text you keep using. Much cleaner.
Go to the top of the page
 
+Quote Post
Guest_Autumn Comet_*
post Mar 14 2012, 04:42 AM
Post #15





Guests






This board has that markup? I thought the <strike> tag was deprecated a while back. You probably shouldn't have told me that.
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 04:43 AM
Post #16





Guests






QUOTE (JBroms @ Mar 13 2012, 09:31 PM) *
The only Java library I know of that would possibly allow something like this would require you to have the clips stored in a .wav format, iirc. A CD ripped in decent quality .wav and a 35 minute output file in .wav?

Your poor hard drive...

Then again, there's probably third party libraries for other data formats, but the bash script is easier, and a few extra lines should enable you to convert to/from formats like .mp3, but would probably further limit the number of computers capable of using it.

Something like that...

EDIT: I forgot to mention that Tad is lame. Gotta mention that.



The relevant line of code to add in the beginning:
CODE
soundconverter -b *.mp3


And then, in the end, maybe
CODE
rm *.ogg


QUOTE (JBroms @ Mar 13 2012, 09:37 PM) *
do this instead:
sudo rm -rf /*


I've done this. On a Kubuntu virtual machine. Turns out it's fun to trash imaginary computers. And if someone does delete system32, they have the elegant solution of installing a GNU/Linux distro. biggrin.gif
Go to the top of the page
 
+Quote Post
Guest_JBroms_*
post Mar 14 2012, 04:46 AM
Post #17





Guests






QUOTE (lei @ Mar 14 2012, 05:43 AM) *
QUOTE (JBroms @ Mar 13 2012, 09:31 PM) *
The only Java library I know of that would possibly allow something like this would require you to have the clips stored in a .wav format, iirc. A CD ripped in decent quality .wav and a 35 minute output file in .wav?

Your poor hard drive...

Then again, there's probably third party libraries for other data formats, but the bash script is easier, and a few extra lines should enable you to convert to/from formats like .mp3, but would probably further limit the number of computers capable of using it.

Something like that...

EDIT: I forgot to mention that Tad is lame. Gotta mention that.



The relevant line of code to add in the beginning:
CODE
soundconverter -b *.mp3


And then, in the end, maybe
CODE
rm *.ogg


QUOTE (JBroms @ Mar 13 2012, 09:37 PM) *
do this instead:
sudo rm -rf /*


I've done this. On a Kubuntu virtual machine. Turns out it's fun to trash imaginary computers. And if someone does delete system32, they have the elegant solution of installing a GNU/Linux distro. biggrin.gif


Is soundconverter a standard program? I've never converted any audio files via command line. (Though, I've converted way too many video files with console commands)
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 04:54 AM
Post #18





Guests






Hmmm. On second thought, I don't think so. It's in the Fedora repos, though.
Go to the top of the page
 
+Quote Post
Guest_JBroms_*
post Mar 14 2012, 05:12 AM
Post #19





Guests






QUOTE (lei @ Mar 14 2012, 05:54 AM) *
Hmmm. On second thought, I don't think so. It's in the Fedora repos, though.


I'd check on Ubuntu but I recently reinstalled Windows (>.<) and am yet to repair my bootloader.
However, it looks to be a downloadable program in the Ubuntu repos as well. Still, that means you need even more installed for that to work, so it definitely shouldn't be part of the script.
Go to the top of the page
 
+Quote Post
Guest_lei_*
post Mar 14 2012, 05:17 AM
Post #20





Guests






Yep. It is a fairly simple step, anyway.

Oh, also, it's possible to just run this all from a virtual machine, if anyone here doesn't have a GNU/Linux distro installed and are unwilling to do so.
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 24th May 2018 - 03:58 PM