| Author |
Message |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Mon Nov 17, 2008 11:21 am Post subject:
wave playback trouble Subject description: dropping entire instruments? |
 |
|
hey y'all, i'm curious how this could possibly happen, it's quite strange.
my code looks like this. there's other stuff going on of course but this is really everything important.
SndBuf snd => dac;
"filename.wav" => snd.read;
while (true) {
1::second=>now;
}
now when i play some wave files it plays them back flawlessly. however, i tried playing back some .wav files that i made and it drops entire instruments out of the playback!! for example one song i wrote starts off with some violin and a drumbeat (and plays back as such in ITunes and Winamp) yet when i play it using this method, the violin cuts out entirely! i tried resaving and renaming the file, converting it to 48 KHz instead of 44.1, etc. etc. etc.
How can that even happen? Last edited by salamanderanagram on Mon Nov 17, 2008 6:54 pm; edited 1 time in total |
|
|
Back to top
|
|
 |
telstarmagikistferrari

Joined: Jun 16, 2008 Posts: 280 Location: Indianapolis, Indiana
Audio files: 43
|
Posted: Mon Nov 17, 2008 5:44 pm Post subject:
|
 |
|
wow. in any case it sounds like a whole hell of a lot of weed was involved.
 |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Mon Nov 17, 2008 6:52 pm Post subject:
|
 |
|
well you are certainly correct about that good sir, but really...
if there is a way to strip individual instruments out of .wav files i'd like to know how!! i simply don't understand it.
EDIT i just copy-pasted the code above into a new file that does nothing but attempt to play a .wav and it still happens... |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Nov 17, 2008 8:16 pm Post subject:
|
 |
|
Ok. My bet is that this is a stereo file and these instruments are exactly 180° out of phase between the left and right channels, then canceling.
Could you try what happens if you use a mono version? If that turns out to be it we can then move on to making stereo work for you but I'd like to try this first. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Mon Nov 17, 2008 9:13 pm Post subject:
|
 |
|
huh.
i had a similar thought and try panning it all left or right and got no results.
but mono works fine... what am i doing wrong? i'm quite a noob at chuck and was just fooling around... |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Fri Nov 21, 2008 10:06 am Post subject:
|
 |
|
| so does anybody know how to play a stereo file in chuck or am i stuck in mono? |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 21, 2008 2:31 pm Post subject:
|
 |
|
I'm fairly sure this should work but I don't quickly have a stereo test file on this computer. Anyway, try this and see how far it gets you;
| Code: |
SndBuf buf;
"myStereoFile.wav" => buf.read;
buf.chan(0) => dac.left;
buf.chan(1) => dac.right;
hour => now; |
_________________ Kassen |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 21, 2008 2:46 pm Post subject:
|
 |
|
After giving it some more thought I now feel you were right to expect a automatic stereo connection. After all; Pan2 has a stereo output and that UGen automatically connects to the dac in stereo if chucked to it.
[edit]
After yet more thought I take that back :¬)
Unlike Pan2 SndBuf has no pre-determined number of channels; it may load a multi-channel wave files *after* it has been connected to the dac, so that would lead to issues. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Fri Nov 21, 2008 4:09 pm Post subject:
|
 |
|
thanks
but no dice. i get a null pointer from that code, maybe some minor error or oversight? i did try several other, similar methods to no avail tho.
EDIT
buf.chan(1) => dac.right;
causes the null pointer which is odd because if you read the number of channels in buf it gives back 2. |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 21, 2008 7:12 pm Post subject:
|
 |
|
| salamanderanagram wrote: |
causes the null pointer which is odd because if you read the number of channels in buf it gives back 2. |
That's weird! I had the same but I had no file loaded. Did you make sure to load a file *before* connecting to the dac? If so this is a bug and should be reported. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Fri Nov 21, 2008 7:27 pm Post subject:
|
 |
|
yeah i used exactly your code except changed the file name of course.
also i put in
buf.channels() =>int ch;
<<<ch>>>;
and it would say 2 channels on every test but when trying to access buf.chan(1) gives an error... weird. |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 21, 2008 8:11 pm Post subject:
|
 |
|
Hmmmm, likely a bug but I just noticed that the docs on SndBuf don't actually mention .chan(). I suppose it could be that SndBuf is only meant to play a single channel but that you can pick which one you'd like to play from multi-channel files (creating the need to use two buf's for stereo). That sounds quite inconvenient though.
I suggest you report the issue to the mailing-list to make sure it's a bug but at the very least *something* is wrong here. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Sun Nov 23, 2008 6:05 pm Post subject:
got it! |
 |
|
after a whole bunch of experimentation and a little bit of consulting the manual, here's how to play a stereo wave file in chuck -
SndBuf sndl;
"sound.wav" => sndl.read;
sndl.channel(0);
sndl=>dac.left;
SndBuf sndr;
"sound.wav" => sndr.read;
sndr.channel(1);
sndr=>dac.right;
hour => now;
probably i'll design a class for this tonight to be contained as one piece! thanks for your help kassen |
|
|
Back to top
|
|
 |
telstarmagikistferrari

Joined: Jun 16, 2008 Posts: 280 Location: Indianapolis, Indiana
Audio files: 43
|
Posted: Mon Nov 24, 2008 5:33 pm Post subject:
|
 |
|
| this is great. well done. economical code! this will be endlessly useful. |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Nov 24, 2008 7:42 pm Post subject:
|
 |
|
A small suggestion;
| Code: |
SndBuf snd[2];
for(int n; n<snd.cap(); n++)
{
"sound.wav" => snd[n].read;
snd[n].channel(n);
//this is equivalent to left&right
snd[n]=>dac.chan(n);
}
hour => now; |
This is a bit smaller but more importantly it'll make controlling the whole thing easier and as you're never typing the same thing twice it's less error-prone. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Tue Nov 25, 2008 11:19 am Post subject:
|
 |
|
| hmmm.... strange i did try something like that and i kept getting this error, like "sndbuf[] has no element 'read()'" but now it's working fine with your code.. wonder what i did wrong. anyway, thanks! |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Tue Nov 25, 2008 11:41 am Post subject:
|
 |
|
| salamanderanagram wrote: | | "sndbuf[] has no element 'read()'" |
That's right, it doesn't. A array of type SndBuf doesn't have a .read() member function but any one element in that array will have one. Similarly; you can add one to a element of a a array of integers but you can't add to the array itself as the array doesn't have a value, you *can* of course add a element to it but that's a different thing).
So in this case;
snd[1].read()
Here the blue part refers to a array of SndBufs, the red points to a specific element (which is a SndBuf) in it and the green refers to that element's member function.
It's important to realise that array locations are just like any other example of a object of that class, they can do the same things but like with anything else you are required to indicate what exact object you'd like to work with. We select from the general to the precise and once we arrive "at the bottom" we can actually interact with it.
I hope this clarifies. This is useful nearly everywhere where we have a group of object that we'd like to treat in a similar way. It nearly always leads to less code, less errors and generally more convenience. _________________ Kassen |
|
|
Back to top
|
|
 |
salamanderanagram
Joined: Apr 08, 2007 Posts: 20 Location: VT
|
Posted: Wed Nov 26, 2008 12:04 pm Post subject:
|
 |
|
| nah i've been programming for 12 years, i understand usually all of this stuff... i must have been doing some esoteric error or stupid syntax mistake of some kind... thanks for the help!! |
|
|
Back to top
|
|
 |
|