OSDN Git Service

リセット
[momiji/momiji_main.git] / Core / Momiji.Sequencer.Wave.h
1 /*
2 [momiji music component library]
3 ---------------------------------------------------------------------
4 Momiji.Sequencer.Midi.Smf.cpp
5         stream component of standard midi file.
6 ---------------------------------------------------------------------
7 Copyright (C) 2011 tyiki badwell {miria@users.sourceforge.jp}.
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program.  If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
21 ---------------------------------------------------------------------
22 */
23 #pragma once
24
25 #using <mscorlib.dll>
26
27 #include "Momiji.Interop.Winmm.h"
28
29 #include "Momiji.Core.Interface.h"
30 #include "Momiji.Core.Buffer.h"
31
32 using namespace System::Runtime;
33
34 namespace Momiji{
35 namespace Sequencer {
36 namespace Wave {
37
38         public ref class WaveStream
39                 : public Core::IStream
40         {
41         public:
42                 enum class TYPE: System::UInt32 
43                 {
44                         HEADER          = 0x52494646L,  //      RIFF
45                         HEADER_R        = 0x46464952L,  //              読み込み用
46                 };
47
48                 enum class FORMAT: System::UInt32
49                 {
50                         WAVE            = 0x57415645L,  //      WAVE
51                         WAVE_R          = 0x45564157L,  //              読み込み用
52                 };
53
54                 enum class SUB: System::UInt32
55                 {
56                         fmt_            = 0x666D7420L,  //      fmt
57                         fmt__R          = 0x20746D66L,  //              読み込み用
58
59                         data            = 0x64617461L,  //      data
60                         data_R          = 0x61746164L,  //              読み込み用
61
62                         LIST            = 0x4C495354L,  //      LIST
63                         LIST_R          = 0x5453494CL,  //              読み込み用
64
65                 };
66
67                 //RIFF Header Chunk
68                 WIN32_DLL_STRUCTLAYOUT value struct RIFFHEADER_CHUNK 
69                 {
70                         System::UInt32  dwType;
71                         System::UInt32  dwLength;
72                         System::UInt32  dwFormat;
73                 };
74
75                 //RIFF Sub Chunk
76                 WIN32_DLL_STRUCTLAYOUT value struct RIFFSUB_CHUNK 
77                 {
78                         System::UInt32  dwType;
79                         System::UInt32  dwLength;
80                 };
81
82         private:
83                 System::IO::MemoryMappedFiles::MemoryMappedFile^                        _mmap;
84                 System::IO::MemoryMappedFiles::MemoryMappedViewAccessor^        _view;
85
86                 Momiji::Interop::Winmm::WaveFormatEx _wfx;
87
88                 System::Int64 _dataStartPosition;
89                 System::UInt32 _dataSize;
90                 System::Int64 _dataSeekPosition;
91
92         public:
93                 WaveStream(System::String^ path);
94                 virtual ~WaveStream();
95
96         protected:
97                 !WaveStream();
98
99         private:
100                 void Open(System::String^ path);
101                 void CheckWave();
102
103         public:
104                 virtual array<Core::IStreamPacket^>^ GetStreamPacket(System::Double deltaTime) {return nullptr;};
105                 virtual void Rewind() {};
106
107                 //System::UInt32 WaveStream::Read(array<System::Byte>^ buffer, System::UInt32 samplesPerBuffer);
108                 System::UInt32 WaveStream::Read(Momiji::Core::Buffer::BufferPool<array<System::Byte>^>::Buffer^ buffer, System::UInt32 samplesPerBuffer);
109
110                 property Momiji::Interop::Winmm::WaveFormatEx format { Momiji::Interop::Winmm::WaveFormatEx get() {return this->_wfx;} } 
111
112         };
113
114         public ref class WaveException
115                 : System::Exception
116         {
117         public:
118                 WaveException(System::String^ v): System::Exception(v){};
119         };
120
121 }
122 }
123 }