action-engine-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +45 -0
- package/README.md +348 -0
- package/actionengine/3rdparty/goblin/goblin.js +9609 -0
- package/actionengine/3rdparty/goblin/goblin.min.js +5 -0
- package/actionengine/camera/actioncamera.js +90 -0
- package/actionengine/camera/cameracollisionhandler.js +69 -0
- package/actionengine/character/actioncharacter.js +360 -0
- package/actionengine/character/actioncharacter3D.js +61 -0
- package/actionengine/core/app.js +430 -0
- package/actionengine/debug/basedebugpanel.js +858 -0
- package/actionengine/display/canvasmanager.js +75 -0
- package/actionengine/display/gl/programmanager.js +570 -0
- package/actionengine/display/gl/shaders/lineshader.js +118 -0
- package/actionengine/display/gl/shaders/objectshader.js +1756 -0
- package/actionengine/display/gl/shaders/particleshader.js +43 -0
- package/actionengine/display/gl/shaders/shadowshader.js +319 -0
- package/actionengine/display/gl/shaders/spriteshader.js +100 -0
- package/actionengine/display/gl/shaders/watershader.js +67 -0
- package/actionengine/display/graphics/actionmodel3D.js +191 -0
- package/actionengine/display/graphics/actionsprite3D.js +230 -0
- package/actionengine/display/graphics/lighting/actiondirectionalshadowlight.js +864 -0
- package/actionengine/display/graphics/lighting/actionlight.js +211 -0
- package/actionengine/display/graphics/lighting/actionomnidirectionalshadowlight.js +862 -0
- package/actionengine/display/graphics/lighting/lightingconstants.js +263 -0
- package/actionengine/display/graphics/lighting/lightmanager.js +789 -0
- package/actionengine/display/graphics/renderableobject.js +44 -0
- package/actionengine/display/graphics/renderers/actionrenderer2D.js +341 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/actionrenderer3D.js +655 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/canvasmanager3D.js +82 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/debugrenderer3D.js +493 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/objectrenderer3D.js +790 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/spriteRenderer3D.js +266 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/sunrenderer3D.js +140 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/waterrenderer3D.js +173 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/weatherrenderer3D.js +87 -0
- package/actionengine/display/graphics/texture/proceduraltexture.js +192 -0
- package/actionengine/display/graphics/texture/texturemanager.js +242 -0
- package/actionengine/display/graphics/texture/textureregistry.js +177 -0
- package/actionengine/input/actionscrollablearea.js +1405 -0
- package/actionengine/input/inputhandler.js +1647 -0
- package/actionengine/math/geometry/geometrybuilder.js +161 -0
- package/actionengine/math/geometry/glbexporter.js +364 -0
- package/actionengine/math/geometry/glbloader.js +722 -0
- package/actionengine/math/geometry/modelcodegenerator.js +97 -0
- package/actionengine/math/geometry/triangle.js +33 -0
- package/actionengine/math/geometry/triangleutils.js +34 -0
- package/actionengine/math/mathutils.js +25 -0
- package/actionengine/math/matrix4.js +785 -0
- package/actionengine/math/physics/actionphysics.js +108 -0
- package/actionengine/math/physics/actionphysicsobject3D.js +164 -0
- package/actionengine/math/physics/actionphysicsworld3D.js +238 -0
- package/actionengine/math/physics/actionraycast.js +129 -0
- package/actionengine/math/physics/shapes/actionphysicsbox3D.js +158 -0
- package/actionengine/math/physics/shapes/actionphysicscapsule3D.js +200 -0
- package/actionengine/math/physics/shapes/actionphysicscompoundshape3D.js +147 -0
- package/actionengine/math/physics/shapes/actionphysicscone3D.js +126 -0
- package/actionengine/math/physics/shapes/actionphysicsconvexshape3D.js +72 -0
- package/actionengine/math/physics/shapes/actionphysicscylinder3D.js +117 -0
- package/actionengine/math/physics/shapes/actionphysicsmesh3D.js +74 -0
- package/actionengine/math/physics/shapes/actionphysicsplane3D.js +100 -0
- package/actionengine/math/physics/shapes/actionphysicssphere3D.js +95 -0
- package/actionengine/math/quaternion.js +61 -0
- package/actionengine/math/vector2.js +277 -0
- package/actionengine/math/vector3.js +318 -0
- package/actionengine/math/viewfrustum.js +136 -0
- package/actionengine/network/ACTIONNETREADME.md +810 -0
- package/actionengine/network/client/ActionNetManager.js +802 -0
- package/actionengine/network/client/ActionNetManagerGUI.js +1709 -0
- package/actionengine/network/client/ActionNetManagerP2P.js +1537 -0
- package/actionengine/network/client/SyncSystem.js +422 -0
- package/actionengine/network/p2p/ActionNetPeer.js +142 -0
- package/actionengine/network/p2p/ActionNetTrackerClient.js +623 -0
- package/actionengine/network/p2p/DataConnection.js +282 -0
- package/actionengine/network/p2p/README.md +510 -0
- package/actionengine/network/p2p/example.html +502 -0
- package/actionengine/network/server/ActionNetServer.js +577 -0
- package/actionengine/network/server/ActionNetServerSSL.js +579 -0
- package/actionengine/network/server/ActionNetServerUtils.js +458 -0
- package/actionengine/network/server/SERVERREADME.md +314 -0
- package/actionengine/network/server/package-lock.json +35 -0
- package/actionengine/network/server/package.json +13 -0
- package/actionengine/network/server/start.bat +27 -0
- package/actionengine/network/server/start.sh +25 -0
- package/actionengine/network/server/startwss.bat +27 -0
- package/actionengine/sound/audiomanager.js +1589 -0
- package/actionengine/sound/soundfont/ACTIONSOUNDFONT_README.md +205 -0
- package/actionengine/sound/soundfont/actionparser.js +718 -0
- package/actionengine/sound/soundfont/actionreverb.js +252 -0
- package/actionengine/sound/soundfont/actionsoundfont.js +543 -0
- package/actionengine/sound/soundfont/sf2playerlicence.txt +29 -0
- package/actionengine/sound/soundfont/soundfont.js +2 -0
- package/dist/action-engine.min.js +328 -0
- package/package.json +35 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# ActionSoundFont - Custom SoundFont Implementation
|
|
2
|
+
|
|
3
|
+
A custom implementation of SoundFont2 playback to replace the 3rd party sf2-player library.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
ActionSoundFont provides identical functionality to the original 3rd party library but is entirely self-contained within the ActionEngine codebase. It includes:
|
|
8
|
+
|
|
9
|
+
- **ActionSoundFont** - Main class providing the SoundFont player API
|
|
10
|
+
- **ActionParser** - SF2 file parser (RIFF/SF2 format)
|
|
11
|
+
- **ActionReverb** - Reverb effect processor
|
|
12
|
+
- **ActionSynthesizer** - Core synthesis engine
|
|
13
|
+
- **ActionSynthesizerNote** - Individual note playback
|
|
14
|
+
|
|
15
|
+
## Files
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
actionengine/sound/
|
|
19
|
+
├── actionsoundfont.js # Main SoundFont player class
|
|
20
|
+
├── actionparser.js # SF2 file parser
|
|
21
|
+
├── actionreverb.js # Reverb effect
|
|
22
|
+
└── audiomanager.js # Audio manager (uses ActionSoundFont)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Migration from 3rd Party Library
|
|
26
|
+
|
|
27
|
+
### Before (3rd party library):
|
|
28
|
+
```html
|
|
29
|
+
<script src="actionengine/3rdparty/sf2-player/parser.js"></script>
|
|
30
|
+
<script src="actionengine/3rdparty/sf2-player/reverb.js"></script>
|
|
31
|
+
<script src="actionengine/3rdparty/sf2-player/sound_font_synth_note.js"></script>
|
|
32
|
+
<script src="actionengine/3rdparty/sf2-player/sound_font_synth.js"></script>
|
|
33
|
+
<script src="actionengine/3rdparty/sf2-player/sf2-player.js"></script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### After (ActionSoundFont):
|
|
37
|
+
```html
|
|
38
|
+
<script src="actionengine/sound/actionreverb.js"></script>
|
|
39
|
+
<script src="actionengine/sound/actionparser.js"></script>
|
|
40
|
+
<script src="actionengine/sound/actionsoundfont.js"></script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Important:** Load files in this order (reverb → parser → soundfont).
|
|
44
|
+
|
|
45
|
+
## API Compatibility
|
|
46
|
+
|
|
47
|
+
ActionSoundFont is a **drop-in replacement** with identical API:
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// Works with both old and new implementation
|
|
51
|
+
const soundFont = new SoundFont(audioContext);
|
|
52
|
+
await soundFont.loadSoundFontFromBase64(base64Data);
|
|
53
|
+
|
|
54
|
+
// Set program and channel
|
|
55
|
+
soundFont.program = 0; // Piano
|
|
56
|
+
soundFont.channel = 0;
|
|
57
|
+
|
|
58
|
+
// Play notes
|
|
59
|
+
soundFont.noteOn(60, 127, 0); // Middle C, max velocity, channel 0
|
|
60
|
+
soundFont.noteOff(60, 127, 0); // Release note
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage in AudioManager
|
|
64
|
+
|
|
65
|
+
The AudioManager already uses the correct API, so no changes are needed:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// From audiomanager.js - already compatible!
|
|
69
|
+
async initializeMIDI() {
|
|
70
|
+
if (this.sf2Player) return;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
this.sf2Player = new SoundFont(this.context);
|
|
74
|
+
await this.sf2Player.loadSoundFontFromBase64(window.TimGM6mb_BASE64);
|
|
75
|
+
this.midiReady = true;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error("[AudioManager] Failed to initialize SF2 player:", error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Implementation Details
|
|
83
|
+
|
|
84
|
+
### ActionSoundFont Class
|
|
85
|
+
Provides the main API surface:
|
|
86
|
+
- `loadSoundFontFromBase64(base64String)` - Load SF2 data
|
|
87
|
+
- `noteOn(note, velocity, channel)` - Play MIDI note
|
|
88
|
+
- `noteOff(note, velocity, channel)` - Stop MIDI note
|
|
89
|
+
- `program` setter/getter - Instrument selection
|
|
90
|
+
- `channel` setter/getter - MIDI channel
|
|
91
|
+
- `bank` setter/getter - Bank selection
|
|
92
|
+
|
|
93
|
+
### ActionParser Class
|
|
94
|
+
Parses SoundFont2 (.sf2) files:
|
|
95
|
+
- RIFF chunk parsing
|
|
96
|
+
- SF2 structure parsing (INFO, sdta, pdta)
|
|
97
|
+
- Preset and instrument extraction
|
|
98
|
+
- Sample data decoding
|
|
99
|
+
- Sample rate adjustment
|
|
100
|
+
|
|
101
|
+
### ActionSynthesizer Class
|
|
102
|
+
Core synthesis engine:
|
|
103
|
+
- 16 MIDI channels
|
|
104
|
+
- Per-channel state (volume, pan, pitch bend, etc.)
|
|
105
|
+
- Instrument and bank management
|
|
106
|
+
- Note-on/note-off handling
|
|
107
|
+
- Percussion support (channel 10)
|
|
108
|
+
|
|
109
|
+
### ActionSynthesizerNote Class
|
|
110
|
+
Individual note playback:
|
|
111
|
+
- ADSR envelope (Attack, Decay, Sustain, Release)
|
|
112
|
+
- Sample playback with looping
|
|
113
|
+
- Pitch bend support
|
|
114
|
+
- Pan and filter effects
|
|
115
|
+
- Reverb integration
|
|
116
|
+
|
|
117
|
+
### ActionReverb Class
|
|
118
|
+
Reverb effect processor:
|
|
119
|
+
- Convolution-based reverb
|
|
120
|
+
- Impulse response generation
|
|
121
|
+
- Dry/wet mix control
|
|
122
|
+
- Filter effects
|
|
123
|
+
- Configurable decay and time
|
|
124
|
+
|
|
125
|
+
## Features Implemented
|
|
126
|
+
|
|
127
|
+
✅ Full SF2 file parsing
|
|
128
|
+
✅ Multi-channel MIDI playback (16 channels)
|
|
129
|
+
✅ Instrument selection (128 programs)
|
|
130
|
+
✅ Bank selection
|
|
131
|
+
✅ ADSR envelope support
|
|
132
|
+
✅ Sample looping
|
|
133
|
+
✅ Pitch bend
|
|
134
|
+
✅ Pan/balance control
|
|
135
|
+
✅ Volume and expression
|
|
136
|
+
✅ Reverb effects
|
|
137
|
+
✅ Percussion mode (channel 10)
|
|
138
|
+
✅ Note velocity
|
|
139
|
+
✅ Sample rate adjustment
|
|
140
|
+
|
|
141
|
+
## Testing
|
|
142
|
+
|
|
143
|
+
To test the implementation:
|
|
144
|
+
|
|
145
|
+
1. Load a SoundFont file (e.g., TimGM6mb)
|
|
146
|
+
2. Play notes through various instruments
|
|
147
|
+
3. Test MIDI features (pitch bend, volume, pan)
|
|
148
|
+
4. Verify percussion on channel 10
|
|
149
|
+
5. Check reverb effects
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// Test script
|
|
153
|
+
const audioContext = new AudioContext();
|
|
154
|
+
const sf = new ActionSoundFont(audioContext);
|
|
155
|
+
|
|
156
|
+
await sf.loadSoundFontFromBase64(soundFontData);
|
|
157
|
+
|
|
158
|
+
// Piano on channel 0
|
|
159
|
+
sf.program = 0;
|
|
160
|
+
sf.channel = 0;
|
|
161
|
+
sf.noteOn(60, 100, 0); // Middle C
|
|
162
|
+
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
sf.noteOff(60, 100, 0);
|
|
165
|
+
}, 1000);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Performance Considerations
|
|
169
|
+
|
|
170
|
+
- **Shared Reverb**: Single reverb instance shared across all channels to reduce memory
|
|
171
|
+
- **Sample Caching**: Parsed samples are cached in the bank set
|
|
172
|
+
- **On-Demand Parsing**: SF2 files are only parsed once during initialization
|
|
173
|
+
- **Web Audio API**: Leverages native browser audio processing
|
|
174
|
+
|
|
175
|
+
## Limitations
|
|
176
|
+
|
|
177
|
+
- Simplified modulator support (full SF2 modulators not implemented)
|
|
178
|
+
- Basic filter implementation (lowpass only for now)
|
|
179
|
+
- Limited LFO support
|
|
180
|
+
- No real-time sample streaming (entire SF2 loaded into memory)
|
|
181
|
+
|
|
182
|
+
## Browser Compatibility
|
|
183
|
+
|
|
184
|
+
Requires modern browsers with:
|
|
185
|
+
- Web Audio API support
|
|
186
|
+
- AudioContext
|
|
187
|
+
- Typed Arrays (Int16Array, Float32Array, Uint8Array)
|
|
188
|
+
- ES6+ features (classes, arrow functions, async/await)
|
|
189
|
+
|
|
190
|
+
## Future Enhancements
|
|
191
|
+
|
|
192
|
+
- [ ] Additional filter types (highpass, bandpass)
|
|
193
|
+
- [ ] LFO (Low Frequency Oscillator) support
|
|
194
|
+
- [ ] More comprehensive modulator support
|
|
195
|
+
- [ ] Real-time SF2 streaming for large files
|
|
196
|
+
- [ ] Additional effect types (chorus, delay)
|
|
197
|
+
- [ ] SoundFont preset browser UI
|
|
198
|
+
|
|
199
|
+
## Credits
|
|
200
|
+
|
|
201
|
+
Based on concepts from the sf2-player library but completely rewritten for ActionEngine.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
Part of ActionEngineJS - see main project license.
|