Skip to content

Commit dfa6104

Browse files
author
dsward2
committed
In AudioMonitor2 runInputBufferOnThread, prime the buffer with some white noise and more insert white noise more actively when the input buffer runs low.
In HTTPStreamingServerController, set the port number according to user settings. In SQLiteController, fix errors in creating a new database file, and importing and updating old database files.
1 parent 0807816 commit dfa6104

22 files changed

Lines changed: 238 additions & 162 deletions

File tree

AACEncoder/AACEncoder.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@
289289
CODE_SIGN_STYLE = Manual;
290290
DEVELOPMENT_TEAM = MMFBWVS455;
291291
ENABLE_HARDENED_RUNTIME = NO;
292-
MACOSX_DEPLOYMENT_TARGET = 10.15;
293292
PRODUCT_NAME = "$(TARGET_NAME)";
294293
PROVISIONING_PROFILE_SPECIFIER = "";
295294
SKIP_INSTALL = YES;
@@ -304,7 +303,6 @@
304303
CODE_SIGN_STYLE = Manual;
305304
DEVELOPMENT_TEAM = MMFBWVS455;
306305
ENABLE_HARDENED_RUNTIME = NO;
307-
MACOSX_DEPLOYMENT_TARGET = 10.15;
308306
PRODUCT_NAME = "$(TARGET_NAME)";
309307
PROVISIONING_PROFILE_SPECIFIER = "";
310308
SKIP_INSTALL = YES;

AudioMonitor/AudioMonitor.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@
287287
CODE_SIGN_IDENTITY = "-";
288288
CODE_SIGN_STYLE = Manual;
289289
DEVELOPMENT_TEAM = MMFBWVS455;
290-
MACOSX_DEPLOYMENT_TARGET = 10.15;
291290
PRODUCT_NAME = "$(TARGET_NAME)";
292291
PROVISIONING_PROFILE_SPECIFIER = "";
293292
SKIP_INSTALL = YES;
@@ -301,7 +300,6 @@
301300
CODE_SIGN_IDENTITY = "-";
302301
CODE_SIGN_STYLE = Manual;
303302
DEVELOPMENT_TEAM = MMFBWVS455;
304-
MACOSX_DEPLOYMENT_TARGET = 10.15;
305303
PRODUCT_NAME = "$(TARGET_NAME)";
306304
PROVISIONING_PROFILE_SPECIFIER = "";
307305
SKIP_INSTALL = YES;

AudioMonitor/AudioMonitor/AudioMonitor2.cpp

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void logAudioConverterProperties()
331331
}
332332
else
333333
{
334-
fprintf(stderr, "AudioMonitor2 AudioConverterGetProperty kAudioConverterPrimeInfo error = %d\n", (int)primeInfoStatus);
334+
fprintf(stderr, "AudioMonitor2 AudioConverterGetProperty kAudioConverterPrimeInfo error = %d (OK)\n", (int)primeInfoStatus);
335335
}
336336

337337

@@ -695,6 +695,7 @@ void * runInputBufferOnThread(void * ptr)
695695
// works in all cases.
696696

697697
const int maxWhiteNoiseBufferLength = 24000;
698+
//const int maxWhiteNoiseBufferLength = 192000;
698699

699700
// instead of silence, send some white noise when needed
700701
char whiteNoiseBuffer[maxWhiteNoiseBufferLength];
@@ -719,15 +720,20 @@ void * runInputBufferOnThread(void * ptr)
719720

720721
//CFTimeInterval inputTimeoutInterval = 0.025f;
721722
//CFTimeInterval inputTimeoutInterval = 20000.0f / sampleRate;
723+
//CFTimeInterval inputTimeoutInterval = 6.0f;
722724
CFTimeInterval inputTimeoutInterval = 6.0f;
723-
725+
724726
float whiteNoiseBufferLengthFloat = (float)sampleRate * (float)inputChannels * inputTimeoutInterval;
725727
int whiteNoiseBufferLength = whiteNoiseBufferLengthFloat;
726728
if (whiteNoiseBufferLength > maxWhiteNoiseBufferLength)
727729
{
728730
whiteNoiseBufferLength = maxWhiteNoiseBufferLength;
729731
}
730-
732+
if (whiteNoiseBufferLength > inputBufferSize)
733+
{
734+
whiteNoiseBufferLength = inputBufferSize;
735+
}
736+
731737
fprintf(stderr, "AudioMonitor2 runInputBufferOnThread inputTimeoutInterval=%f, whiteNoiseBufferLength=%d\n", inputTimeoutInterval, whiteNoiseBufferLength);
732738

733739
int packetIndex = 0;
@@ -740,6 +746,14 @@ void * runInputBufferOnThread(void * ptr)
740746
fprintf(stderr, "AudioMonitor2 runInputBufferOnThread inputCircularBuffer=%p, circularBufferLength = %d\n", &inputCircularBuffer, circularBufferLength);
741747

742748
unsigned char * rtlsdrBuffer = (unsigned char *)malloc(circularBufferLength);
749+
750+
UInt32 initialBytesAvailableCount = 0;
751+
int initial_ioctl_result = ioctl(STDIN_FILENO, FIONREAD, &initialBytesAvailableCount);
752+
if (initialBytesAvailableCount < whiteNoiseBufferLength / 2)
753+
{
754+
fprintf(stderr, "AudioMonitor2 priming input buffer\n");
755+
bool produceBytesPrimeResult = TPCircularBufferProduceBytes(&inputCircularBuffer, &whiteNoiseBuffer, whiteNoiseBufferLength / 2);
756+
}
743757

744758
UInt64 loopCount = 0;
745759

@@ -839,6 +853,35 @@ void * runInputBufferOnThread(void * ptr)
839853
}
840854
}
841855

856+
// send some white noise during periods of silence (no audio input received from source, the buffer is empty)
857+
/*
858+
int32_t bytesAvailableToReadCount = 0;
859+
void * circularBufferDataPtr = TPCircularBufferTail(&inputCircularBuffer, &bytesAvailableToReadCount); // get pointer to read buffer
860+
if (bytesAvailableToReadCount == 0)
861+
{
862+
bool produceBytesResult = TPCircularBufferProduceBytes(&inputCircularBuffer, &whiteNoiseBuffer, whiteNoiseBufferLength);
863+
864+
//fprintf(stderr, "AudioMonitor2 runInputBufferOnThread - buffer is empty, write white noise - interval=%f, inputTimeoutInterval=%f, length=%d\n", currentAbsoluteTime - lastValidPacketAbsoluteTime, inputTimeoutInterval, whiteNoiseBufferLength);
865+
866+
lastValidPacketAbsoluteTime = currentAbsoluteTime;
867+
}
868+
*/
869+
870+
// send some white noise during periods of silence (no audio input received from source, the buffer is low)
871+
int32_t bytesAvailableToReadCount = 0;
872+
void * circularBufferDataPtr = TPCircularBufferTail(&inputCircularBuffer, &bytesAvailableToReadCount); // get pointer to read buffer
873+
if (bytesAvailableToReadCount < 1000)
874+
{
875+
//bool produceBytesResult = TPCircularBufferProduceBytes(&inputCircularBuffer, &whiteNoiseBuffer, whiteNoiseBufferLength);
876+
bool produceBytesResult = TPCircularBufferProduceBytes(&inputCircularBuffer, &whiteNoiseBuffer, 500);
877+
878+
fprintf(stderr, "bytesAvailableToReadCount = %d, whiteNoiseBufferLength = %d, currentAbsoluteTime = %f\n", bytesAvailableToReadCount, whiteNoiseBufferLength, currentAbsoluteTime);
879+
//fprintf(stderr, "AudioMonitor2 runInputBufferOnThread - buffer is low, write white noise - interval=%f, inputTimeoutInterval=%f, length=%d\n", currentAbsoluteTime - lastValidPacketAbsoluteTime, inputTimeoutInterval, whiteNoiseBufferLength);
880+
881+
lastValidPacketAbsoluteTime = currentAbsoluteTime;
882+
}
883+
884+
/*
842885
// In scanning mode with squelch, we might not get continuous audio data,
843886
// so send some white noise periodically during long periods of silence
844887
if (currentAbsoluteTime - lastValidPacketAbsoluteTime >= inputTimeoutInterval)
@@ -849,6 +892,7 @@ void * runInputBufferOnThread(void * ptr)
849892
850893
lastValidPacketAbsoluteTime = currentAbsoluteTime;
851894
}
895+
*/
852896

853897
usleep(1000);
854898

LocalRadio copy2-Info.plist

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>$(MARKETING_VERSION)</string>
21+
<key>CFBundleVersion</key>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
23+
<key>ITSAppUsesNonExemptEncryption</key>
24+
<false/>
25+
<key>LSApplicationCategoryType</key>
26+
<string>public.app-category.entertainment</string>
27+
<key>LSMinimumSystemVersion</key>
28+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
29+
<key>NSAppTransportSecurity</key>
30+
<dict>
31+
<key>NSAllowsArbitraryLoads</key>
32+
<true/>
33+
</dict>
34+
<key>NSHumanReadableCopyright</key>
35+
<string>Copyright © 2017-2020 ArkPhone LLC. All rights reserved.</string>
36+
<key>NSLocationWhenInUseUsageDescription</key>
37+
<string>The current location is used to query the U.S. FCC database to find local radio stations.</string>
38+
<key>NSMainNibFile</key>
39+
<string>MainMenu</string>
40+
<key>NSPrincipalClass</key>
41+
<string>NSApplication</string>
42+
</dict>
43+
</plist>

LocalRadio.xcodeproj/project.pbxproj

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -508,36 +508,6 @@
508508
name = "Copy RTL-SDR Tools";
509509
runOnlyForDeploymentPostprocessing = 0;
510510
};
511-
0EA2128A1ED72D4D004DE453 /* Copy Icecast Admin Files */ = {
512-
isa = PBXCopyFilesBuildPhase;
513-
buildActionMask = 2147483647;
514-
dstPath = icecast/admin;
515-
dstSubfolderSpec = 7;
516-
files = (
517-
);
518-
name = "Copy Icecast Admin Files";
519-
runOnlyForDeploymentPostprocessing = 0;
520-
};
521-
0EA212941ED72D7A004DE453 /* Copy Icecast Web Files */ = {
522-
isa = PBXCopyFilesBuildPhase;
523-
buildActionMask = 2147483647;
524-
dstPath = icecast/web;
525-
dstSubfolderSpec = 7;
526-
files = (
527-
);
528-
name = "Copy Icecast Web Files";
529-
runOnlyForDeploymentPostprocessing = 0;
530-
};
531-
0EA2129E1ED72DAB004DE453 /* Copy Icecast Doc Files */ = {
532-
isa = PBXCopyFilesBuildPhase;
533-
buildActionMask = 2147483647;
534-
dstPath = icecast/doc;
535-
dstSubfolderSpec = 7;
536-
files = (
537-
);
538-
name = "Copy Icecast Doc Files";
539-
runOnlyForDeploymentPostprocessing = 0;
540-
};
541511
/* End PBXCopyFilesBuildPhase section */
542512

543513
/* Begin PBXFileReference section */
@@ -1406,6 +1376,7 @@
14061376
0E87456023F3683900D34F1B /* StreamingServer.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = StreamingServer.xcodeproj; path = StreamingServer/StreamingServer.xcodeproj; sourceTree = "<group>"; };
14071377
0E880CF51EDA606E007BEB99 /* viewfavorite.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = viewfavorite.html; sourceTree = "<group>"; };
14081378
0E88520F241A0FCE001AF9E2 /* LocalRadio Clean-Up.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "LocalRadio Clean-Up.app"; sourceTree = "<group>"; };
1379+
0E8852AC241BDE06001AF9E2 /* LocalRadio copy2-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "LocalRadio copy2-Info.plist"; path = "/Volumes/Mercury/Users/dsward/Documents/ArkPhone_LLC_Projects/LocalRadio/LocalRadio copy2-Info.plist"; sourceTree = "<absolute>"; };
14091380
0E96D56623FB80B5002F8968 /* StreamingServerController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StreamingServerController.h; sourceTree = "<group>"; };
14101381
0E96D56723FB80B5002F8968 /* StreamingServerController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StreamingServerController.m; sourceTree = "<group>"; };
14111382
0E96D56A23FC84A2002F8968 /* fix_sox.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = fix_sox.sh; sourceTree = "<group>"; };
@@ -2756,6 +2727,7 @@
27562727
children = (
27572728
0E274FD121DF54F600337560 /* Assets.xcassets */,
27582729
0E274FCF21DF546D00337560 /* Info.plist */,
2730+
0E8852AC241BDE06001AF9E2 /* LocalRadio copy2-Info.plist */,
27592731
0E9B3CB021DC0C17004A91E6 /* LocalRadio-Source */,
27602732
0E84C9BB1ED935E00065864B /* SQLiteLibrary-master */,
27612733
0E1BA0EF1EC8929800130DB9 /* sox-build */,
@@ -4423,9 +4395,6 @@
44234395
0E4ECFB91EAB633B00D2157B /* Resources */,
44244396
0E4ED21E1EABDC6900D2157B /* Copy Tools */,
44254397
0E0C693D1F1C9D4800A7EE5E /* Run Fix stereodemux Script */,
4426-
0EA2128A1ED72D4D004DE453 /* Copy Icecast Admin Files */,
4427-
0EA212941ED72D7A004DE453 /* Copy Icecast Web Files */,
4428-
0EA2129E1ED72DAB004DE453 /* Copy Icecast Doc Files */,
44294398
0E84C9A31ED8FFC90065864B /* Run Copy HTTP Files Script */,
44304399
0E82BEBD2201586B0042D275 /* Run fix_rtl_sdr_tools.sh Script */,
44314400
0E82BEB422012A850042D275 /* Copy RTL-SDR Tools */,
@@ -5689,7 +5658,7 @@
56895658
CLANG_WARN_SUSPICIOUS_MOVE = YES;
56905659
CLANG_WARN_UNREACHABLE_CODE = YES;
56915660
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
5692-
CODE_SIGN_IDENTITY = "-";
5661+
CODE_SIGN_IDENTITY = "";
56935662
COPY_PHASE_STRIP = NO;
56945663
DEBUG_INFORMATION_FORMAT = dwarf;
56955664
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5746,7 +5715,7 @@
57465715
CLANG_WARN_SUSPICIOUS_MOVE = YES;
57475716
CLANG_WARN_UNREACHABLE_CODE = YES;
57485717
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
5749-
CODE_SIGN_IDENTITY = "-";
5718+
CODE_SIGN_IDENTITY = "";
57505719
COPY_PHASE_STRIP = NO;
57515720
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
57525721
ENABLE_NS_ASSERTIONS = NO;

LocalRadio/LocalRadio-Source/AppDelegate.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ - (IBAction)updateCurrentTasksText:(id)sender
303303
[tasksString appendString:streamingServerTasksString];
304304
}
305305

306+
[tasksString appendString:@"\n\n"];
307+
306308
dispatch_async(dispatch_get_main_queue(), ^{
307309
[self.statusCurrentTasksTextView setString:tasksString];
308310
});

LocalRadio/LocalRadio-Source/LocalRadioAppSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
@class SQLiteController;
1212
@class AppDelegate;
1313

14+
#define kCurrentLocalRadioConfigVersion 5
15+
1416
@interface LocalRadioAppSettings : NSObject
1517

1618
@property (strong) IBOutlet AppDelegate * appDelegate;

LocalRadio/LocalRadio-Source/LocalRadioAppSettings.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ - (void) registerDefaultSettings
1616
{
1717
// set default key-store values in local_radio_config SQLite table
1818

19-
[self setDefaultInteger:4 forKey:@"LocalRadioConfigVersion"];
19+
[self setDefaultInteger:kCurrentLocalRadioConfigVersion forKey:@"LocalRadioConfigVersion"];
2020

2121
[self setDefaultInteger:17002 forKey:@"LocalRadioServerHTTPPort"];
2222
[self setDefaultInteger:17004 forKey:@"StreamingServerHTTPPort"];
@@ -26,14 +26,14 @@ - (void) registerDefaultSettings
2626

2727
[self setDefaultInteger:1 forKey:@"CaptureStderr"];
2828

29-
[self setDefaultValue:@"64000" forKey:@"AACBitrate"];
29+
[self setDefaultValue:@"128000" forKey:@"AACBitrate"];
3030
}
3131

3232
- (void) setDefaultSettings
3333
{
3434
// set default key-store values in local_radio_config SQLite table
3535

36-
[self setInteger:4 forKey:@"LocalRadioConfigVersion"];
36+
[self setInteger:kCurrentLocalRadioConfigVersion forKey:@"LocalRadioConfigVersion"];
3737

3838
[self setInteger:17002 forKey:@"LocalRadioServerHTTPPort"];
3939
[self setInteger:17004 forKey:@"StreamingServerHTTPPort"];
@@ -43,7 +43,7 @@ - (void) setDefaultSettings
4343

4444
[self setInteger:1 forKey:@"CaptureStderr"];
4545

46-
[self setValue:@"64000" forKey:@"AACBitrate"];
46+
[self setValue:@"128000" forKey:@"AACBitrate"];
4747
}
4848

4949

@@ -105,7 +105,7 @@ - (void) setInteger:(NSInteger)aInteger forKey:(NSString *)key
105105
{
106106
NSNumber * integerNumber = [NSNumber numberWithInteger:aInteger];
107107

108-
[self.sqliteController storeLocalRadioAppSettingsValue:integerNumber ForKey:key];
108+
[self.sqliteController storeLocalRadioAppSettingsValue:integerNumber forKey:key];
109109
}
110110

111111

@@ -135,7 +135,7 @@ - (NSString *) valueForKey:(NSString *)key
135135

136136
- (void) setValue:(NSString *)aString forKey:(NSString *)key
137137
{
138-
[self.sqliteController storeLocalRadioAppSettingsValue:aString ForKey:key];
138+
[self.sqliteController storeLocalRadioAppSettingsValue:aString forKey:key];
139139
}
140140

141141

LocalRadio/LocalRadio-Source/SQLiteController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- (void)startSQLiteConnection;
1616

1717
- (id)localRadioAppSettingsValueForKey:(NSString *)aKey;
18-
- (void)storeLocalRadioAppSettingsValue:(id)aValue ForKey:(NSString *)aKey;
18+
- (void)storeLocalRadioAppSettingsValue:(id)aValue forKey:(NSString *)aKey;
1919

2020
- (NSArray *)allFrequencyRecords;
2121
- (NSDictionary *)frequencyRecordForID:(NSString *)frequencyIDString;

0 commit comments

Comments
 (0)