Skip to content

Commit b8b1550

Browse files
authored
Merge branch 'master' into nofmod
2 parents c468077 + d753765 commit b8b1550

File tree

19 files changed

+276
-167
lines changed

19 files changed

+276
-167
lines changed

.github/workflows/of.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v4
3434
- name: Docker Step
35-
run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.73 bash"
35+
run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.74 bash"
3636
# - name: Determine Release
3737
# id: vars
3838
# shell: bash
@@ -173,12 +173,12 @@ jobs:
173173
suffix: arm-linux-gnueabihf,
174174
alladdons: 1,
175175
}
176-
- {
177-
libs: armv7l,
178-
multistrap_arch: armhf,
179-
suffix: arm-linux-gnueabihf,
180-
alladdons: 1,
181-
}
176+
# - {
177+
# libs: armv7l,
178+
# multistrap_arch: armhf,
179+
# suffix: arm-linux-gnueabihf,
180+
# alladdons: 1,
181+
# }
182182
- {
183183
libs: aarch64,
184184
multistrap_arch: arm64,

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
---
44

5-
Copyright (c) 2004 - openFrameworks Community
5+
Copyright (c) 2025 - openFrameworks Community
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
88

addons/ofxiOS/src/video/AVFoundationVideoGrabber.mm

+39-33
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,23 @@ - (instancetype)init {
5353
}
5454

5555
- (BOOL)initCapture:(int)framerate capWidth:(int)w capHeight:(int)h{
56-
AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[
57-
AVCaptureDeviceTypeBuiltInWideAngleCamera,
58-
AVCaptureDeviceTypeBuiltInTelephotoCamera,
59-
AVCaptureDeviceTypeBuiltInUltraWideCamera,
60-
AVCaptureDeviceTypeBuiltInDualCamera,
61-
AVCaptureDeviceTypeBuiltInDualWideCamera,
62-
AVCaptureDeviceTypeBuiltInTripleCamera,
63-
AVCaptureDeviceTypeExternal
64-
] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
56+
57+
NSMutableArray *deviceTypes = [NSMutableArray arrayWithObjects:AVCaptureDeviceTypeBuiltInWideAngleCamera,
58+
AVCaptureDeviceTypeBuiltInTelephotoCamera,
59+
AVCaptureDeviceTypeBuiltInUltraWideCamera,
60+
AVCaptureDeviceTypeBuiltInDualCamera,
61+
AVCaptureDeviceTypeBuiltInDualWideCamera,
62+
AVCaptureDeviceTypeBuiltInTripleCamera,
63+
AVCaptureDeviceTypeBuiltInTrueDepthCamera, nil];
64+
if (@available(iOS 17.0, macCatalyst 17.0, tvOS 17.0, *)) {
65+
if (&AVCaptureDeviceTypeContinuityCamera != nil) {
66+
[deviceTypes addObject:AVCaptureDeviceTypeContinuityCamera];
67+
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInLiDARDepthCamera];
68+
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInTrueDepthCamera];
69+
[deviceTypes addObject:AVCaptureDeviceTypeExternal];
70+
}
71+
}
72+
AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:deviceTypes mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
6573

6674
NSArray<AVCaptureDevice *> *devices = discoverySession.devices;
6775
if([devices count] > 0) {
@@ -251,28 +259,26 @@ -(CGImageRef)getCurrentFrame{
251259
-(std::vector <std::string>)listDevices{
252260
std::vector <std::string> deviceNames;
253261
NSArray<AVCaptureDevice *> *devices;
254-
if (@available(iOS 17.0, *)) {
255-
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[
256-
AVCaptureDeviceTypeBuiltInWideAngleCamera,
257-
AVCaptureDeviceTypeBuiltInTelephotoCamera,
258-
AVCaptureDeviceTypeBuiltInUltraWideCamera,
259-
AVCaptureDeviceTypeBuiltInDualCamera,
260-
AVCaptureDeviceTypeBuiltInDualWideCamera,
261-
AVCaptureDeviceTypeBuiltInTripleCamera,
262-
AVCaptureDeviceTypeExternal
263-
] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
264-
devices = session.devices;
265-
} else {
266-
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[
267-
AVCaptureDeviceTypeBuiltInWideAngleCamera,
268-
AVCaptureDeviceTypeBuiltInTelephotoCamera,
269-
AVCaptureDeviceTypeBuiltInUltraWideCamera,
270-
AVCaptureDeviceTypeBuiltInDualCamera,
271-
AVCaptureDeviceTypeBuiltInDualWideCamera,
272-
AVCaptureDeviceTypeBuiltInTripleCamera,
273-
] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
274-
devices = session.devices;
275-
}
262+
263+
NSMutableArray *deviceTypes = [NSMutableArray arrayWithObjects:AVCaptureDeviceTypeBuiltInWideAngleCamera,
264+
AVCaptureDeviceTypeBuiltInTelephotoCamera,
265+
AVCaptureDeviceTypeBuiltInUltraWideCamera,
266+
AVCaptureDeviceTypeBuiltInDualCamera,
267+
AVCaptureDeviceTypeBuiltInDualWideCamera,
268+
AVCaptureDeviceTypeBuiltInTripleCamera,
269+
AVCaptureDeviceTypeBuiltInTrueDepthCamera,
270+
nil
271+
];
272+
if (@available(iOS 17.0, macCatalyst 17.0, tvOS 17.0, *)) {
273+
if (&AVCaptureDeviceTypeContinuityCamera != nil) {
274+
[deviceTypes addObject:AVCaptureDeviceTypeContinuityCamera];
275+
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInLiDARDepthCamera];
276+
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInTrueDepthCamera];
277+
[deviceTypes addObject:AVCaptureDeviceTypeExternal];
278+
}
279+
}
280+
AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:deviceTypes mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
281+
devices = discoverySession.devices;
276282
int i=0;
277283
for (AVCaptureDevice * captureDevice in devices){
278284
deviceNames.push_back([captureDevice.localizedName UTF8String]);
@@ -320,8 +326,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
320326
// Create a CGImageRef from the CVImageBufferRef
321327
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
322328

323-
CGContextRef newContext = CGBitmapContextCreate(baseAddress, widthIn, heightIn, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
324-
CGImageRef newImage = CGBitmapContextCreateImage(newContext);
329+
CGContextRef newContext = CGBitmapContextCreate(baseAddress, widthIn, heightIn, 8, bytesPerRow, colorSpace, (CGBitmapInfo)kCGBitmapByteOrder32Little | (CGBitmapInfo)kCGImageAlphaPremultipliedFirst);
330+
CGImageRef newImage = CGBitmapContextCreateImage(newContext);
325331

326332
CGImageRelease(currentFrame);
327333
currentFrame = CGImageCreateCopy(newImage);

examples/sound/audioInputExample/src/ofApp.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ void ofApp::setup(){
99

1010
soundStream.printDeviceList();
1111

12-
int bufferSize = 256;
12+
int bufferSize = 512;
1313

14-
left.assign(bufferSize, 0.0);
15-
right.assign(bufferSize, 0.0);
14+
1615
volHistory.assign(400, 0.0);
1716

1817
bufferCounter = 0;
@@ -28,14 +27,16 @@ void ofApp::setup(){
2827
// settings.device = devices[4];
2928

3029
// you can also get devices for an specific api
31-
// auto devices = soundStream.getDevicesByApi(ofSoundDevice::Api::PULSE);
30+
// auto devices = soundStream.getDeviceList(ofSoundDevice::Api::PULSE);
3231
// settings.device = devices[0];
3332

3433
// or get the default device for an specific api:
3534
// settings.api = ofSoundDevice::Api::PULSE;
3635

3736
// or by name
37+
3838
auto devices = soundStream.getMatchingDevices("default");
39+
3940
if(!devices.empty()){
4041
settings.setInDevice(devices[0]);
4142
}
@@ -51,6 +52,11 @@ void ofApp::setup(){
5152
settings.bufferSize = bufferSize;
5253
soundStream.setup(settings);
5354

55+
bufferSize = soundStream.getBufferSize();
56+
57+
left.assign(bufferSize, 0.0);
58+
right.assign(bufferSize, 0.0);
59+
5460
}
5561

5662
//--------------------------------------------------------------
@@ -167,8 +173,8 @@ void ofApp::audioIn(ofSoundBuffer & input){
167173

168174
//lets go through each sample and calculate the root mean square which is a rough way to calculate volume
169175
for (size_t i = 0; i < input.getNumFrames(); i++){
170-
left[i] = input[i*2]*0.5;
171-
right[i] = input[i*2+1]*0.5;
176+
left[i] = input[i]*0.5;
177+
right[i] = input[i]*0.5;
172178

173179
curVol += left[i] * left[i];
174180
curVol += right[i] * right[i];

examples/sound/audioOutputExample/src/ofApp.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ void ofApp::setup(){
4141
// settings.setOutDevice(devices[0]);
4242
// }
4343

44-
#ifdef TARGET_LINUX
44+
4545
// Latest linux versions default to the HDMI output
4646
// this usually fixes that. Also check the list of available
4747
// devices if sound doesn't work
48+
49+
//settings.setApi(ofSoundDevice::MS_ASIO);
50+
//settings.setApi(ofSoundDevice::MS_WASAPI);
51+
//settings.setApi(ofSoundDevice::MS_DS);
52+
4853
auto devices = soundStream.getMatchingDevices("default");
4954
if(!devices.empty()){
5055
settings.setOutDevice(devices[0]);
5156
}
52-
#endif
57+
58+
59+
5360

5461
settings.setOutListener(this);
5562
settings.sampleRate = sampleRate;

libs/openFrameworks/events/ofEvents.cpp

+20-13
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ double ofGetLastFrameTime() {
4848
if (window) {
4949
return window->events().getLastFrameTime();
5050
} else {
51-
return 0.f;
51+
return 0.0;
5252
}
5353
}
5454

@@ -123,9 +123,10 @@ int ofGetPreviousMouseY() {
123123
}
124124

125125
ofCoreEvents::ofCoreEvents()
126-
: targetRate(0)
126+
: targetRate(60.0)
127+
, fixedRateTimeNanos(std::chrono::nanoseconds(ofGetFixedStepForFps(60.0)))
127128
, bFrameRateSet(false)
128-
, fps(60)
129+
, fps(60.0)
129130
, currentMouseX(0)
130131
, currentMouseY(0)
131132
, previousMouseX(0)
@@ -183,6 +184,7 @@ void ofCoreEvents::enable() {
183184

184185
void ofCoreEvents::setTimeModeSystem() {
185186
timeMode = System;
187+
fps.setTimeMode(timeMode);
186188
}
187189

188190
ofTimeMode ofCoreEvents::getTimeMode() const {
@@ -192,11 +194,13 @@ ofTimeMode ofCoreEvents::getTimeMode() const {
192194
void ofCoreEvents::setTimeModeFixedRate(uint64_t nanosecsPerFrame) {
193195
timeMode = FixedRate;
194196
fixedRateTimeNanos = std::chrono::nanoseconds(nanosecsPerFrame);
197+
fps.setTimeMode(timeMode);
195198
}
196199

197200
void ofCoreEvents::setTimeModeFiltered(float alpha) {
198201
timeMode = Filtered;
199202
fps.setFilterAlpha(alpha);
203+
fps.setTimeMode(timeMode);
200204
}
201205

202206
//--------------------------------------
@@ -210,13 +214,18 @@ void ofCoreEvents::setFrameRate(int _targetRate) {
210214
bFrameRateSet = false;
211215
} else {
212216
bFrameRateSet = true;
213-
targetRate = _targetRate;
217+
targetRate = static_cast<float>(_targetRate);
214218

215219
// uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate;
216220
// timer.setPeriodicEvent(nanosPerFrame);
217221

218-
timerFps.setFps(targetRate);
222+
timerFps.setFps(_targetRate);
223+
fps.setTargetFPS(targetRate);
224+
if (timeMode == FixedRate) {
225+
ofSetTimeModeFixedRate(ofGetFixedStepForFps(targetRate));
226+
}
219227
}
228+
220229
}
221230

222231
bool ofCoreEvents::getTargetFrameRateEnabled() const {
@@ -301,15 +310,8 @@ bool ofCoreEvents::notifyUpdate() {
301310

302311
//------------------------------------------
303312
bool ofCoreEvents::notifyDraw() {
304-
auto attended = ofNotifyEvent(draw, voidEventArgs);
305-
306-
if (bFrameRateSet) {
307-
// timer.waitNext();
308-
timerFps.waitNext();
309-
}
310-
311313
if (fps.getNumFrames() == 0) {
312-
if (bFrameRateSet) fps = ofFpsCounter(targetRate);
314+
if (bFrameRateSet) fps = ofFpsCounter(targetRate, timeMode);
313315
} else {
314316
/*if(ofIsVerticalSyncEnabled()){
315317
float rate = ofGetRefreshRate();
@@ -318,7 +320,12 @@ bool ofCoreEvents::notifyDraw() {
318320
lastFrameTime = intervals*1000000/rate;
319321
}*/
320322
}
323+
if (bFrameRateSet) {
324+
// timer.waitNext();
325+
timerFps.waitNext();
326+
}
321327
fps.newFrame();
328+
auto attended = ofNotifyEvent(draw, voidEventArgs);
322329
return attended;
323330
}
324331

libs/openFrameworks/events/ofEvents.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class ofCoreEvents {
406406
bool notifyDragEvent(ofDragInfo info);
407407

408408
private:
409-
float targetRate;
409+
float targetRate = 60.0f;
410410
bool bFrameRateSet;
411411
ofTimerFps timerFps;
412412
// ofTimer timer;
@@ -420,7 +420,7 @@ class ofCoreEvents {
420420
int modifiers = 0;
421421

422422
enum TimeMode {
423-
System,
423+
System = 0,
424424
FixedRate,
425425
Filtered,
426426
} timeMode

libs/openFrameworks/sound/ofRtAudioSoundStream.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,16 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
140140

141141
try {
142142
if (settings.getApi() != ofSoundDevice::Api::UNSPECIFIED) {
143+
ofLogNotice() << "Initialing RtAudio Requested API: " << settings.getApi();
143144
audio = std::make_shared<RtAudio>(toRtAudio(settings.getApi()));
144145
}else{
146+
ofLogNotice() << "Initialing RtAudio with UNSPECIFIED API";
145147
audio = std::make_shared<RtAudio>();
146148
}
149+
ofLogNotice() << "Initialized RtAudio with API: " << RtAudio::getApiName(audio->getCurrentApi());
147150
}
148151
catch (std::exception &error) {
149-
ofLogError() << error.what();
152+
ofLogError() << "Failed to initialize RtAudio: " << error.what();
150153
return false;
151154
}
152155

@@ -155,6 +158,7 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
155158
if (settings.numInputChannels > 0) {
156159
if (!settings.getInDevice()) {
157160
ofSoundDevice device;
161+
device.api = settings.getApi();
158162
device.deviceID = audio->getDefaultInputDevice();
159163
settings.setInDevice(device);
160164
}
@@ -165,6 +169,7 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
165169
if (settings.numOutputChannels > 0) {
166170
if (!settings.getOutDevice()) {
167171
ofSoundDevice device;
172+
device.api = settings.getApi();
168173
device.deviceID = audio->getDefaultOutputDevice();
169174
settings.setOutDevice(device);
170175
}

libs/openFrameworks/sound/ofSoundBaseTypes.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ std::string toString(ofSoundDevice::Api api){
2222
case ofSoundDevice::MS_DS:
2323
return "MS DirectShow";
2424
default:
25-
return "Unkown API";
25+
return "Unknown API";
2626
}
2727
}
2828

2929

3030
void ofBaseSoundStream::printDeviceList() const {
3131
ofLogNotice("ofBaseSoundStream::printDeviceList") << std::endl;
3232
#ifndef TARGET_EMSCRIPTEN
33-
for(int i=ofSoundDevice::ALSA; i<ofSoundDevice::NUM_APIS; ++i){
34-
ofSoundDevice::Api api = (ofSoundDevice::Api)i;
33+
std::vector<ofSoundDevice::Api> platformApis;
34+
#ifdef TARGET_LINUX
35+
platformApis = { ofSoundDevice::ALSA, ofSoundDevice::PULSE, ofSoundDevice::OSS, ofSoundDevice::JACK };
36+
#elif defined(TARGET_OSX)
37+
platformApis = { ofSoundDevice::OSX_CORE };
38+
#elif defined(TARGET_WIN32)
39+
platformApis = { ofSoundDevice::MS_WASAPI, ofSoundDevice::MS_ASIO, ofSoundDevice::MS_DS };
40+
#endif
41+
for (auto api : platformApis) {
3542
auto devices = getDeviceList(api);
36-
if(!devices.empty()){
43+
if (!devices.empty()) {
3744
ofLogNotice("ofBaseSoundStream::printDeviceList") << "Api: " << toString(api);
3845
ofLogNotice("ofBaseSoundStream::printDeviceList") << devices;
3946
}

0 commit comments

Comments
 (0)