コード例 #1
0
        public void Load(string filename)
        {
            if (player != null)
            {
                player.Stop();
                player.Dispose();
            }

            if (reader != null)
            {
                reader.Dispose();
                reader.Unload();
            }

            reader = new GmeReader(filename);

            volumeSampleProvider = new VolumeSampleProvider(reader.ToSampleProvider());

            var waveOut = new WaveOut {
                DeviceNumber = -1
            };

            waveOut.Init(volumeSampleProvider);

            player = waveOut;
        }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        float x = 3;
        float y = 10;

        Debug.Log(add(x, y));

        // IntPtr emuOut = IntPtr.Zero;

        var path = Application.streamingAssetsPath + "/sample2.nsf";

        Debug.Log(path);
        GmeReader reader = new GmeReader(path);



        int size = reader.TrackInfo.playLength;

        // IntPtr wavPtr = AquesTalk_Synthe(ref aqtk_voice, koeSjisBytes, ref size);
        Debug.Log("size : " + size);

        //成功判定
        // if (wavPtr == IntPtr.Zero)
        // {
        //     Debug.LogError("ERROR: 音声生成に失敗しました。不正な文字が使われた可能性があります");
        // }

        //C#で扱えるようにマネージド側へコピー
        byte[] byte_data = new byte[size];
        reader.Read(byte_data, 0, size);
        // Marshal.Copy(wavPtr, byte_data, 0, size);

        //アンマネージドポインタは用が無くなった瞬間に解放
        // AquesTalk_FreeWave(wavPtr);

        //float配列に変換
        float[] float_data = CreateRangedRawData(byte_data, 0, size / 2, 1, BIT_16);

        //audioClip作成
        AudioClip audioClip = AudioClip.Create("gme", float_data.Length, 2, 44100, false);

        audioClip.SetData(float_data, 0);
        m_Audio.clip = audioClip;

        //再生
        m_Audio.Play();
    }
コード例 #3
0
ファイル: Program.cs プロジェクト: ishidafuu/isdf_nsf
 static Program()
 {
     reader = new GmeReader(fileName);
 }