expo-juce 0.2.1 → 0.2.2

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.
@@ -4,7 +4,7 @@ NS_ASSUME_NONNULL_BEGIN
4
4
 
5
5
  @interface ExpoJuceBridge : NSObject
6
6
 
7
- + (void)initialize;
7
+ + (void)setup;
8
8
  + (void)shutdown;
9
9
  + (void)playToneWithFrequency:(double)frequency duration:(double)duration;
10
10
  + (void)setFrequency:(double)frequency;
@@ -3,8 +3,9 @@
3
3
 
4
4
  @implementation ExpoJuceBridge
5
5
 
6
- + (void)initialize {
7
- [[JuceToneGenerator sharedInstance] initialize];
6
+ + (void)setup {
7
+ // Access the singleton — audio engine is initialized in its -init
8
+ [JuceToneGenerator sharedInstance];
8
9
  }
9
10
 
10
11
  + (void)shutdown {
@@ -5,7 +5,7 @@ public class ExpoJuceModule: Module {
5
5
  Name("ExpoJuce")
6
6
 
7
7
  OnCreate {
8
- ExpoJuceBridge.initialize()
8
+ ExpoJuceBridge.setup()
9
9
  }
10
10
 
11
11
  OnDestroy {
@@ -136,19 +136,34 @@ private:
136
136
  }
137
137
 
138
138
  - (void)initialize {
139
+ if (self.audioEngine) {
140
+ NSLog(@"[ExpoJuce] Audio engine already initialized, skipping");
141
+ return;
142
+ }
143
+
144
+ NSLog(@"[ExpoJuce] Initializing audio engine...");
139
145
  NSError *error = nil;
140
146
 
141
147
  AVAudioSession *audioSession = [AVAudioSession sharedInstance];
142
148
  [audioSession setCategory:AVAudioSessionCategoryPlayback
143
149
  withOptions:AVAudioSessionCategoryOptionMixWithOthers
144
150
  error:&error];
145
- if (error) NSLog(@"Error setting audio session category: %@", error);
151
+ if (error) {
152
+ NSLog(@"[ExpoJuce] Error setting audio session category: %@", error);
153
+ error = nil;
154
+ }
146
155
 
147
156
  [audioSession setPreferredIOBufferDuration:0.005 error:&error]; // 5ms
148
- if (error) NSLog(@"Error setting buffer duration: %@", error);
157
+ if (error) {
158
+ NSLog(@"[ExpoJuce] Error setting buffer duration: %@", error);
159
+ error = nil;
160
+ }
149
161
 
150
162
  [audioSession setActive:YES error:&error];
151
- if (error) NSLog(@"Error activating audio session: %@", error);
163
+ if (error) {
164
+ NSLog(@"[ExpoJuce] Error activating audio session: %@", error);
165
+ error = nil;
166
+ }
152
167
 
153
168
  self.audioEngine = [[AVAudioEngine alloc] init];
154
169
  AVAudioFormat *format = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100.0 channels:2];
@@ -174,7 +189,11 @@ private:
174
189
 
175
190
  [self.audioEngine prepare];
176
191
  [self.audioEngine startAndReturnError:&error];
177
- if (error) NSLog(@"Error starting audio engine: %@", error);
192
+ if (error) {
193
+ NSLog(@"[ExpoJuce] Error starting audio engine: %@", error);
194
+ } else {
195
+ NSLog(@"[ExpoJuce] Audio engine started successfully");
196
+ }
178
197
  }
179
198
 
180
199
  - (void)shutdown {
@@ -186,6 +205,7 @@ private:
186
205
  }
187
206
 
188
207
  - (void)playToneWithFrequency:(double)frequency duration:(double)duration {
208
+ NSLog(@"[ExpoJuce] playTone freq=%.1f dur=%.0f engine=%p running=%d", frequency, duration, self.engine, self.audioEngine.isRunning);
189
209
  if (!self.engine) return;
190
210
 
191
211
  self.engine->setFrequency(frequency);
@@ -229,10 +249,12 @@ private:
229
249
  }
230
250
 
231
251
  - (void)noteOn {
252
+ NSLog(@"[ExpoJuce] noteOn (engine=%p, audioEngine running=%d)", self.engine, self.audioEngine.isRunning);
232
253
  if (self.engine) self.engine->noteOn();
233
254
  }
234
255
 
235
256
  - (void)noteOff {
257
+ NSLog(@"[ExpoJuce] noteOff");
236
258
  if (self.engine) self.engine->noteOff();
237
259
  }
238
260
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-juce",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Realtime DSP w/C++ & JUCE",
5
5
  "type": "module",
6
6
  "main": "build/index.js",