Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Audio Library Problem
Started by FileEX Feb 07 2019 05:59 AM

- - - - -
No replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

FileEX

[GLOBAL: userInfoPane.html]
FileEX
  • Observer

  • 2 posts
  • Corona SDK

Hi, I use Corony SDK for a very long time, but I just created an account. But to the point ... I have three sounds, which one is still playing and two after chosing answer. My problem is with small sounds (ok and bad sound effect). I made 'What is song?' game. 

local sound,channel;
local q;

audio.reserveChannels(2);

local tsnd = audio.loadSound('assests/snds/bada.mp3');
local tsnd2 = audio.loadSound('assests/snds/oka.mp3');

audio.setVolume(1.0);

local function soundEffect(g)
    audio.play(g == 1 and tsnd2 or tsnd, {channels = 2});
end

local function generateQuestion()
    -- [...]


    if not audio.isChannelActive(1) then
        sound = audio.loadSound('assests/snds/'..songsData[q].src);
        channel = audio.play(sound, {channels = 1});
    end
end

local function onTouch(event)
    if event.target == answer1 then
        if songsData[q].gAnswer == 1 then
            soundEffect(1);
            table.insert(resSongs, q);
            save();
        else
            soundEffect(2);
        end
    --[...]
    end

    if sound then
        audio.stop(channel);
        channel = nil;
        audio.dispose(sound);
        sound = nil;
    end
end

soundEffect playing sound (tsnd or tsnd2) if i chose good or bad answer. And it's working fine, but if music (sound) is finished and i chose any answer, soundEffect don't work. It's working only when music (sound varaible) is playing. I have been struggling with this since yesterday.

Sorry for my eng. I can only read, I can not grammar, that's why my sentences may are not understandable.




[topic_controls]
[/topic_controls]