MixSound

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

MixSound

Post by 7feet »

I started working on a mixer (a lot of the code was already in the PadSound script), and I finally got something working. Keep in mind this is MAD BETA, so don't blame me if something blows up. It shouldn't, but I gotta say that. I've only tried it on Winduhs, I'm sure someone'll let me know if it falls over on Mac or Linux. For that matter, I have no idea how to check between PowerPC and Intel Macs, so there's another bit of wierdness to throw in there, but hopefully it's not a problem on this one.

Okay, so you have a soundtrack loaded. Run the script, choose another sound file, and it will be mixed in to the soundtrack at the current frame, saved under the same name as the soundtrack but with "MIXED" stuck on the end of the filename (e.g. music.wav for your original soundtrack file would give you musicMIXED.wav), and that new file is assigned as the soundtrack. It's also saved in the same directory as the original soundtrack

Both the soundtrack file and the one you are mixing in MUST be of the exact same type. Meaning, If the soundtrack is 44.1K 16 bit, then the other file must be the same. They can be pretty much anything you want, any sample rate, 8 or 16 bit, but they have to be the same or wierd stuff will happen. Also, the new sountrack is the same length as the original one, so if your soundtrack ends at frame 100, and you try to mix in a sound at frame 101, you won't get anything but the original soundtrack.

I have to throw in some stuff to keep track of the files you added so you can undo stuff and move things around, but you can play with it for the moment.

sf_MixSoundBETA1.zip

Theres all kinds of stuff I'll probably do with it, but this is what I got for now. Happy playing. Also, if you didn't figure it yet, it's a menu script.
CowsCanFly
Posts: 67
Joined: Mon Jul 24, 2006 7:00 am
Location: israel
Contact:

Post by CowsCanFly »

WOW thx alot!!!!!!

I really enjoyed the Padsound scripts, and the others too!!!


EDIT:

I tried that, and it didnt work...

Here's a link.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Oops, forgot to finish the 8 bit stuff ( the 16 bit was being much more of a pain) should be better now, updated the file at the link above. Sorry 'bout that.
CowsCanFly
Posts: 67
Joined: Mon Jul 24, 2006 7:00 am
Location: israel
Contact:

Post by CowsCanFly »

7feet wrote:Oops, forgot to finish the 8 bit stuff ( the 16 bit was being much more of a pain) should be better now, updated the file at the link above. Sorry 'bout that.
np thx


EDIT:

OOOOKKKKKK.... WTF happened?!?!?!

I changed the script, and when i open moho i see that!?

I i can't even see the script in the menu?!
Last edited by CowsCanFly on Thu Aug 31, 2006 9:49 am, edited 1 time in total.
User avatar
Rai López
Posts: 2243
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

...EY, 7feet! THANK YOU! :D It doesn't works to me yet cause something strange seems occurs when I treat to add any sound... it seem like if your script create an empty/silence file and then import it to the proyect, hmmm... Curious! Although in the other hand could be that I don't have proved it enough... Anyway I'm sure a lot of valuable lines of code are inside that interesting script and make me think it could be applied in so many ways... For example! Do you know that proporsal remember me to another proyect which I was working in the past? Well, the case is that I usually prefer Embedded Scripts solutions than Menu scripts solutions as you know, for the real time response and automatation posibilities, yes... for that reason when you stared with your first PadSound script I started too to think how it could be more practice or "versatile" and I started to do some curious (and useless) eXpErIMenTs that I always have wanted to show you so...

--> :!: Download My Useless Moho Audio Mixer Now! :!: <--

...As you can see the script is very simple and rough, and at the moment only can be usefull to syncronize, add silences and play with sound re-timing to planificate the animation in consecuence because, obiously, the resulting mixed soundtrack can't be exported... Anyway I think the essence is there and the possibility of use Swich Layers to can make and see changes on the fly and maintaining the sound files (and all the paths) grouped and visible in the proyect could be a great advance to achieve some audio liberty and ejoyment inside Moho... Because of this I think that "mixing" this way of work with your audio treatment to get that the separated sound tracks can be mixed in an only one soundtrack and imported again to the proyect every time any audio change be made by user, could make this script usefull and with great possibilities :) ...Hmmm, do you think something like that could be possible? Well, anyway... THANKS for all!

PS: And... sorry for that your 45 seconds :roll:
Last edited by Rai López on Thu Aug 31, 2006 3:57 pm, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Hey, CowsCanFly, I did a dumb syntactic thang 'cause I had to go to work. silly typing error kinda thing and I think i's fixed, but I'll check it right now.
Last edited by 7feet on Thu Aug 31, 2006 1:08 pm, edited 1 time in total.
CowsCanFly
Posts: 67
Joined: Mon Jul 24, 2006 7:00 am
Location: israel
Contact:

Post by CowsCanFly »

7feet wrote:Hey, CowsCanFly, I did a dumb syntactic thang 'cause I had to go to work. silly rtping error kinda thing and I think i's fixed, but I'll check it right now.
Thank you a lot 7feet!!!!!

*downloading*

EDIT:
aha...

It worked!!!! but not that good..... i chose a soundrack mixed with a small .wav file (rifle), and it was mixedm but it added 10 MB to the original file and it sounded like a modem conection (very high toooooooooooooooooooooooooooooooooooooo)

and they both were wav files?!
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Hey, CowsCanFly, I did a dumb syntactic thang 'cause I had to go to work. silly typing error kinda thing and I think i's fixed, but I'll check it right now.

...
Aw, hell, I know it works for 44.1 16bit stereo files, so let's start there, huh?

Ramón - Sorry, I said it was beta. but it does work for 16 bit files on my machine, if you can at least tell me the specific errror that comes up, I can fix it. I don't think the embedded bit would work fo this, because it's a lot of processing (WAV files are a LOT of data for LUA). However, I do see some possibility maybe, if it would just recompute when you went to the zero frame and changed something. But for now, the next thing would be to store the frames and associated paths to WAV files at the end of the new soundtrack file the same way that the phonemes were stored at the end of files in my Myna script (I killed myself on that one and then LM threw Papagao out there right after, hope that doesn't happen on this one -- well, maybe they will throw in some more audio stuff for Anime Studio, I could do a lot more if I could work in the core instead of Lua). So there would be a LIST block after the audio data that would have all the frames and the audio files that should be there.

Like I said, it takes the new file and runs it like PadSound first, and then mixes it with the Soundtrack file. So if there's some bit or frequency or mono/stereo discrepancy, the results might be wierd. But for now 16bit files will mix together right. I'll put in some error checking, and mixing stereo or mono 8 or 16 bit is pretty simple. But you'll still have to keep the sampling frequency the same as the original soundtrack (I'll put a notice if they don't match) there's no way I'm going to try to code a proper resampler into it.

Like I said, I used most of the code from PadSound, so I just need to tweak it a litttle so it just mixes the sound into the soundtrack at the proper place instead of doing the padding first. Just wanted to get a working model out there.

Okay, I'm going to sleep now.
Last edited by 7feet on Thu Aug 31, 2006 1:08 pm, edited 1 time in total.
CowsCanFly
Posts: 67
Joined: Mon Jul 24, 2006 7:00 am
Location: israel
Contact:

Post by CowsCanFly »

7feet wrote:Hey, CowsCanFly, blah blah blah

Okay, I'm going to sleep now.
Good night... :lol:
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

CowsCanFly- the original (assigned soundtrack) file length shouldn't change, so I have obviously done some thing Very Stupid. Gimme a second to throw some error checking in here. Please, somebody try 2 files you know are 16 bit together, so I can at least know the code works on somebody else's mahine for what I did the original test for. This is the first script I ever threw out there before it was tweaked and idiotproofed ( me being the idiot), so some help is good.
CowsCanFly
Posts: 67
Joined: Mon Jul 24, 2006 7:00 am
Location: israel
Contact:

Post by CowsCanFly »

7feet wrote:CowsCanFly- the original (assigned soundtrack) file length shouldn't change, so I have obviously done some thing Very Stupid. Gimme a second to throw some error checking in here. Please, somebody try 2 files you know are 16 bit together, so I can at least know the code works on somebody else's mahine for what I did the original test for. This is the first script I ever threw out there before it was tweaked and idiotproofed ( me being the idiot), so some help is good.
np i'll be your beta tester... :wink:
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Thanks! Need to have some structure...
Post Reply