Cog/Preferences/Preferences/OutputPane.m
Christopher Snowhill 708c7dc721 Headphone Virtualization: Implement customization
Implement the ability to configure and select an HRIR preset to use with
the HRIR filter, or remove the preset. It will validate the file's
usefulness before setting it for the player to use.

Also, fixed back center channel filtering for 7.0 format audio.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-25 21:30:33 -08:00

67 lines
2 KiB
Objective-C

//
// OutputPane.m
// Preferences
//
// Created by Vincent Spader on 9/4/06.
// Copyright 2006 Vincent Spader. All rights reserved.
//
#import "OutputPane.h"
#import "HeadphoneFilter.h"
@implementation OutputPane
- (NSString *)title
{
return NSLocalizedPrefString(@"Output");
}
- (NSImage *)icon
{
if (@available(macOS 11.0, *))
return [NSImage imageWithSystemSymbolName:@"hifispeaker.2.fill" accessibilityDescription:nil];
return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"output"]];
}
- (IBAction) takeDeviceID:(id)sender
{
NSDictionary *device = [[outputDevices selectedObjects] objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject: device forKey:@"outputDevice"];
}
- (IBAction)setHrir:(id)sender
{
NSArray *fileTypes = @[@"wav", @"wv"];
NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:NO];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setFloatingPanel:YES];
[panel setAllowedFileTypes:fileTypes];
NSString * oldPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"hrirPath"];
if ( oldPath != nil )
[panel setDirectoryURL:[NSURL fileURLWithPath:oldPath]];
NSInteger result = [panel runModal];
if(result == NSModalResponseOK)
{
NSString * path = [[panel URL] path];
if ([NSClassFromString(@"HeadphoneFilter") validateImpulseFile:[NSURL fileURLWithPath:path]])
[[NSUserDefaults standardUserDefaults] setValue:[[panel URL] path] forKey:@"hrirPath"];
else {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Invalid impulse"];
[alert setInformativeText:@"The selected file does not conform to the HeSuVi HRIR specification."];
[alert addButtonWithTitle:@"Ok"];
[alert runModal];
}
}
}
- (IBAction)clearHrir:(id)sender
{
[[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"hrirPath"];
}
@end