0
0

Hello there I’m writing from France then please excuse my pigeon english.
I’m novice in C# and i’ve to make a program that move a sound from the left to the right side of my stereo helmet. I use Microsoft Visual C#2008 express and I’d like to have some code like this under to begin in good conditions. Thanks

[quote:2nlg7pd0]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMOD;

namespace ConsoleApplication1
{
class Program
{

    static void Main(string[] args)
    {
        // Please can u put here the minimum code wich sounds from left to right          
    }
}[/quote:2nlg7pd0]
  • You must to post comments
0
0

The example ‘3d’ should give you a good idea.

  • You must to post comments
0
0

Thanx a1psx for your answer,

I’ve seen the 3D example but i think it’s to hard for me for a beginning.
Can you give me a very short example in C# that shows me how to use
FSOUD_Init?

I’ve tried this but I have the message that FSOUND_Init does not exist in this context

Thanx

[code:3codkn4u]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMOD;

namespace ConsoleApplication1
{
class Program
{

    static void Main(string[] args)
    {          
       FSOUND_Init(44100, 16, 0);                    
    }
}

}
[/code:3codkn4u]

  • You must to post comments
0
0

I’m back after hours of work.
With this code i have mistakes with setVolume setFrequency and setPan.
Can you tell me the way to how to use them better?
I’ve been trying to use 3D example but I don’t why it does not work.
Thanx

[code:1eipwy7y]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMOD;

namespace ConsoleApplication1
{
public class Channel
{
class gestionSons
{
private FMOD.System system = null;
private FMOD.Sound sound = null;
private FMOD.Channel channel = null;
uint version = 0;
FMOD.RESULT result;

        private void ERRCHECK(FMOD.RESULT result, int v)
        {
            if (result != FMOD.RESULT.OK)
            {
                Console.WriteLine("  PB  ----> " + result + " " + v);
                Environment.Exit(-1);
            }
        }

        public void toutInitialiser()
        {
            system = new FMOD.System();
            sound = new FMOD.Sound();
            channel = new FMOD.Channel();

            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result, 0);

            result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);
            ERRCHECK(result, 1);

            result = channel.setVolume(33.20F);
            ERRCHECK(result, 2);

            result = channel.setFrequency(12040.44F);
            ERRCHECK(result, 3);

            float pan = (float)(4) / 512.0f;
            result = channel.setPan(pan);
            //result = channel.setFrequency(223.44F);
            ERRCHECK(result, 4);

        }

    }


    static void Main(string[] args)
    {
        gestionSons ngt = new gestionSons();
        ngt.toutInitialiser();
    }
}

}[/code:1eipwy7y]

  • You must to post comments
0
0

[code:8y7arkgb] system = new FMOD.System();
sound = new FMOD.Sound();
channel = new FMOD.Channel(); [/code:8y7arkgb]

Do not use "new" with these classes.

[code:8y7arkgb]
result = channel.setVolume(33.20F); [/code:8y7arkgb]
the channel hasn’t been created yet. This is meaningless and will most likely return FMOD_ERR_INVALID_HANDLE. To create a valid channel handle you must use the system object and a sound object.

First load a sound file using a FMOD.Sound object
[code:8y7arkgb] result = system.createSound("../../../../examples/media/drumloop.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._3D), ref sound);[/code:8y7arkgb]

Now that you have loaded a sound, play that sound using the system object
[code:8y7arkgb] result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, true, ref channel);[/code:8y7arkgb]

after you have done these two things the channel will be valid you can use setVolume, setFrequency and setPan.

Something I noticed is you’re trying to set the volume to 33.2, that is not a valid value. The range for setVolume is 0.0 – 1.0

If you’re finding the 3d example too complicated, the play sound example is a little simpler.

-Pete

  • You must to post comments
0
0

Thanx PeterStirling for your help,

first here my code you helped me to do :

[code:1kzhllh3]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMOD;
using FMODNet;

namespace ConsoleApplication1
{
public class Channel
{
class gestionSons
{
private FMOD.System system = null;
private FMOD.Sound sound = null;
private FMOD.Channel channel = null;
uint version = 0;
private static CHANNEL_CALLBACK channelCallback;
FMOD.RESULT result;

        private void ERRCHECK(FMOD.RESULT result, int v)
        {
            Console.WriteLine("  Passage  ----> " + result + " " + v);
            if (result != FMOD.RESULT.OK)
            {
                Console.WriteLine("  PB  ----> " + result + " " + v);
                Environment.Exit(-1);
            }
        }

        public void toutInitialiser()
        {                              
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result, 0);

            result = system.getVersion(ref version);
            ERRCHECK(result, 1);

            result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);
            ERRCHECK(result, 2);

            result = system.createSound("C:/Documents and Settings/IEC/Bureau/ConsoleApplication1/ConsoleApplication1/jaguar.wav", FMOD.MODE._3D, ref sound);
            ERRCHECK(result, 3);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, true, ref channel);
            ERRCHECK(result, 4);
        }
    }


    static void Main(string[] args)
    {
        gestionSons ngt = new gestionSons();
        ngt.toutInitialiser();
    }
}

}
[/code:1kzhllh3]

good news no error message in compilation mode but with this no sound on my speakers.

As you said to me I have tried to use playsound example for csharp but when I tried to run it there is a problem with return FMOD_System_GetDriverInfo(systemraw, id, name, namelen, ref guid); in fmod.cs. It’s IndexOutOfRangeException error. The message in MV C# 2008 is : Avertissement : Du code non managé a provoqué un dépassement de capacité de mémoire tampon StringBuilder. Le processus peut devenir instable. Une capacité insuffisante a été allouée à StringBuilder avant son marshaling. In english it sounds like an out of memory problem. Well, thanx for your help. I work hard to understand this FMOD library wich I am sure is very powerfull.

  • You must to post comments
0
0

Looking at your system.playSound-line, it seems you are starting the sound paused (third parameter). Changing that to false may solve your problem.

  • You must to post comments
0
0

thanx I will try later on monday.

  • You must to post comments
0
0

I’m back here just to thanx all for your help. NisseBosseLasse : with false it solved my problem and I heard for the first time the voice of the jaguar.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.