0
0

Am I right? I am new in FMOD and C#, but as far as I understand, the channel is NULL before playSound() is called. Here is the code:
[code:3itbt08i]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FMOD.System system;
private FMOD.Channel channel;
private FMOD.Sound sound;
private FMOD.ChannelGroup group;
private void ERRCHK(FMOD.RESULT result)
{
if (result != FMOD.RESULT.OK)
{
MessageBox.Show(FMOD.Error.String(result));
}
}

    private void Form1_Load(object sender, EventArgs e)
    {
        FMOD.RESULT result;
        result = FMOD.Factory.System_Create(ref system);
        ERRCHK(result);
        result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);            
        ERRCHK(result);
        result = system.createChannelGroup(null, ref group);
        ERRCHK(result);
        //doesn't work. channel = null 
        result = channel.setChannelGroup(group); 
        ERRCHK(result);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        FMOD.RESULT result;
        result = system.createStream(@"e:\sjs\mix1-01.mp3", FMOD.MODE.SOFTWARE, ref sound);
        ERRCHK(result);
        //doesn't work. channel = null
        result = channel.setChannelGroup(group); 
        ERRCHK(result);
        result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
        ERRCHK(result);
        //works fine - channel is created by system.playSound()
        result = channel.setChannelGroup(group);
        ERRCHK(result);
    }
}

}
[/code:3itbt08i]
If true, this is very uncomfortable way to work with channel groups if I need to pause, set channel group and unpause. If false, tell me pls where is the wrong piece of code. Thanks.

  • You must to post comments
0
0

[quote="brett":3h5t55xe]yes, you have to do it afterwards. Playsound gives you a handle to a channel. before that is is nothing.
Why would it be uncomfortable? It is the same as setting the volume during playback, all you are doing is adding 1 more line of code (channel.setPaused(false)) and changing false to true in playsound.[/quote:3h5t55xe]
Ok, of course, one more line of code isn’t a problem. But I am talking about the design. I have a main class AudioEngine(), which is taking care about the global FMOD operations – main volume etc. In this class I have two group channels – bussA and bussB. This class has a members of a class called Player, this class is actually playing the files – Play, Stop, FadeOut, FadeIn etc. and is managing the sounds and channels. Well. from my point of view, the best is to assign a Player’s channel group at creation time, which is not possible in this situation. I have to implement this functionality in the Player.Play() method and to make bussA and bussB public in the AudioEngine class. That is why I said “uncomfortable” 😆 Thank you:)

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.