Hi,

I got done with installing SDL and I wrote a simple program that opens the
audio device allocates both channels to the mixer, sets the volume of one of
the channels to be 0 , loads a wav file and then plays it twice one after
another with a delay in between. I have pasted the code below.

use SDL;
use SDL::Mixer;
use SDL::Mixer::Channels;
use SDL::Mixer::Samples;



 SDL::init(SDL_INIT_AUDIO);
 SDL::Mixer::open_audio( 44100, AUDIO_S16, 2, 4096 );
 SDL::Mixer::Channels::allocate_channels( 2 );
SDL::Mixer::Channels::volume(1,0);
 my $chunk = SDL::Mixer::Samples::load_WAV('C:\1ksil1ch.wav');

 SDL::Mixer::Channels::play_channel( 1, $chunk, 0 );

 SDL::delay(10000);
SDL::Mixer::Channels::halt_channel( 1 );


 SDL::Mixer::Channels::play_channel( 2, $chunk, 0 );
 SDL::delay(10000);

 SDL::Mixer::close_audio();


The questions I have are:
1) When you say channel, do you mean one set of Left and Right Channels.
This is because I saw then in this case, for the first condition of
play_channel (when it was supposed to play to channel 1), it played the wave
file in both the right and left channel and in the second case (when it was
supposed to play to channel 2) there was no sound on either channels. Is
there a way for me to access the left and right channel separately?

2)Also, I played another sound file which was just an instance of a person
saying the syllable "ta" and when i played that file using these settings,
the pitch of the sound changed. I noticed that when I increased the sampling
frequency from 44100 to 154100, was when the sound was the correct pitch.
How is this happening? Is it something I am doing?

I hope you can help,

Thanks

On Wed, Jul 20, 2011 at 2:08 PM, Anjali Menon <[email protected]>wrote:

> Thanks Kartik
>
>
> On Wed, Jul 20, 2011 at 12:03 PM, Kartik Thakore <[email protected]
> > wrote:
>
>> To work with perl, I suggest you learn CPAN. It is how all this will
>> be installed for you.
>>
>> cpan SDL
>>
>> Should work.  If you have trouble just bug us at [email protected] .
>> Also when replying to these threads CC [email protected]
>>
>> On Wed, Jul 20, 2011 at 11:35 AM, Anjali Menon <[email protected]>
>> wrote:
>> > At differing times yes but with an overlap. That was what most others
>> could
>> > not do. There is nothing in the docs for SDL::Mixer that say that it
>> cannot
>> > be done so I guess I'll just have to try it. Also, is there any way of
>> > installing this without getting git. Even if there is an older version
>> I'm
>> > ok with it if you could point me to it. I'm sorry for so many questions.
>> > I've never worked with perl before and there is something I need to get
>> done
>> > really fast thus the hurry. Thank you,
>> >
>> > Anjali
>> >
>> > On Wed, Jul 20, 2011 at 6:16 AM, My <[email protected]> wrote:
>> >>
>> >> This should be possible. Just to be clear you want to play different
>> wavs
>> >> on different channels at differing times. Right? Have you read the
>> >> SDL::Mixer::* docs? Is anything unclear?
>> >>
>> >> Kartik Thakore
>> >>
>> >> On 2011-07-20, at 3:45 AM, Anjali Menon <[email protected]>
>> wrote:
>> >>
>> >> > Hi Kartik,
>> >> >
>> >> > I have been going through the SDL::Mixer installation files and I had
>> >> > several questions about that. I am trying to write a program that
>> will play
>> >> > a certain wav file in one channel and somewhere in the middle of that
>> file
>> >> > it'll start playing another wav file in the other channel. Firstly,
>> is is
>> >> > possible with the SDL::Mixer::Channels extension to run two instances
>> of a
>> >> > player independent of eachother. I tried Win32::MediaPlayer and
>> Win32::Sound
>> >> > and both of them will stop a file that is currently playing if they
>> are
>> >> > given another play command. Can you tell me if SDL_Mixer can do this?
>> Thanks
>> >> > a lot for your help,
>> >> >
>> >> > Anjali
>> >
>> >
>>
>
>

Reply via email to