Skip to content

Commit

Permalink
another refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ujifgc committed Jun 13, 2022
1 parent ea7bb80 commit 6ecd1c4
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 334 deletions.
3 changes: 3 additions & 0 deletions Builds/VisualStudio2019/MultiChannelAudioCapture_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,9 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Source\asio\asio.h" />
<ClInclude Include="..\..\Source\asio\asiosys.h" />
<ClInclude Include="..\..\Source\asio\iasiodrv.h" />
<ClInclude Include="..\..\Source\asio_api.h" />
<ClInclude Include="..\..\Source\asio_callbacks_wrapper.h" />
<ClInclude Include="..\..\Source\core.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@
<Filter Include="JUCE Library Code">
<UniqueIdentifier>{7ED5A90E-41AF-A1EF-659B-37CEEAB9BA61}</UniqueIdentifier>
</Filter>
<Filter Include="MultiChannelAudioCapture\Source\asio">
<UniqueIdentifier>{5f0b9395-ec0e-4331-a28c-e87ed6541bda}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\Source\Main.cpp">
Expand Down Expand Up @@ -2484,6 +2487,15 @@
<Filter>MultiChannelAudioCapture\Source</Filter>
</ClInclude>
<ClInclude Include="resource.h" />
<ClInclude Include="..\..\Source\asio\asio.h">
<Filter>MultiChannelAudioCapture\Source\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\asio\asiosys.h">
<Filter>MultiChannelAudioCapture\Source\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\asio\iasiodrv.h">
<Filter>MultiChannelAudioCapture\Source\asio</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="C:\JUCE\modules\juce_core\native\java\README.txt">
Expand Down
Binary file modified Builds/VisualStudio2019/resources.aps
Binary file not shown.
8 changes: 4 additions & 4 deletions Builds/VisualStudio2019/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

IDR_VERSION VERSIONINFO
FILEVERSION 2022,6,6,2
PRODUCTVERSION 2022,6,6,2
FILEVERSION 2022,6,13,1
PRODUCTVERSION 2022,6,13,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -32,12 +32,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Igor Bochkariov"
VALUE "FileDescription", "Multi Channel Audio Capture"
VALUE "FileVersion", "2022.6.6.2"
VALUE "FileVersion", "2022.6.13.1"
VALUE "InternalName", "mcac.exe"
VALUE "LegalCopyright", "Copyright (C) 2022"
VALUE "OriginalFilename", "mcac.exe"
VALUE "ProductName", "Multi Channel Audio Capture"
VALUE "ProductVersion", "2022.6.6.2"
VALUE "ProductVersion", "2022.6.13.1"
END
END
BLOCK "VarFileInfo"
Expand Down
62 changes: 30 additions & 32 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,42 @@ FileLogger *logger = nullptr;
LogLevel log_level = LogLevel::Debug;
MainComponent* main_component = nullptr;

class MCACApplication : public juce::JUCEApplication {
class MainWindow : public juce::DocumentWindow {
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainWindow)

public:
MainWindow(juce::String name) : DocumentWindow(name, juce::Desktop::getInstance().getDefaultLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId), DocumentWindow::allButtons) {
setUsingNativeTitleBar(true);
main_component = new MainComponent();
setContentOwned(main_component, true);

setResizable(true, true);
const int fixed_width = 10 + 315 + 20 + 285 + 10;
setResizeLimits(fixed_width, 300, 8000, 8000);
centreWithSize(getWidth(), getHeight());
DocumentWindow::setName(getMainTitle());
Component::setVisible(true);
}

void closeButtonPressed() override {
JUCEApplication::getInstance()->systemRequestedQuit();
}
};

class MCACApplication : public juce::JUCEApplication {
std::unique_ptr<MainWindow> mainWindow;

public:
MCACApplication() {}

const juce::String getApplicationName() override { return ProjectInfo::projectName; }
const juce::String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }

void initialise (const juce::String& commandLine) override {
void initialise(const juce::String& commandLine) override {
if (commandLine != "") instance_name = commandLine;

appdata_folder = File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() + "\\" APP_NAME;
appdata_folder = File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() + "\\" + APP_NAME;

File folder(appdata_folder);
if (!folder.exists()) folder.createDirectory();
Expand All @@ -28,7 +52,7 @@ class MCACApplication : public juce::JUCEApplication {

settings_file = appdata_folder + "\\settings.ini";

mainWindow.reset (new MainWindow (getApplicationName()));
mainWindow.reset(new MainWindow (getApplicationName()));
}

void shutdown() override {
Expand All @@ -44,37 +68,11 @@ class MCACApplication : public juce::JUCEApplication {
quit();
}

void anotherInstanceStarted (const juce::String& /*commandLine*/) override {
void anotherInstanceStarted(const juce::String& /*commandLine*/) override {
// When another instance of the app is launched while this one is running,
// this method is invoked, and the commandLine parameter tells you what
// the other instance's command-line arguments were.
}

class MainWindow : public juce::DocumentWindow {
public:
MainWindow (juce::String name) : DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel() .findColour (juce::ResizableWindow::backgroundColourId), DocumentWindow::allButtons) {
setUsingNativeTitleBar(true);
main_component = new MainComponent();
setContentOwned(main_component, true);

setResizable(true, true);
const int fixed_width = 10 + 315 + 20 + 285 + 10;
setResizeLimits(fixed_width, 300, 8000, 8000);
centreWithSize(getWidth(), getHeight());
setName(getMainTitle());
setVisible(true);
}

void closeButtonPressed() override {
JUCEApplication::getInstance()->systemRequestedQuit();
}

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
};

private:
std::unique_ptr<MainWindow> mainWindow;
};

START_JUCE_APPLICATION (MCACApplication)
START_JUCE_APPLICATION(MCACApplication)
20 changes: 10 additions & 10 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ void MainComponent::paint (Graphics& g) {
}

void MainComponent::resized() {
if (device != nullptr && device->get_device_status() == DeviceStatus::Open) {
ui_device_sample_rate.setText(String(device->get_sample_rate(), 0), dontSendNotification);
ui_device_sample_type.setText(device->get_sample_type() == ASIOSTInt32LSB ? "Int32" : "Float32", dontSendNotification);
ui_device_in_channels.setText("In: " + String(device->get_input_channel_names().size()), dontSendNotification);
ui_device_out_channels.setText("Out: " + String(device->get_output_channel_names().size()), dontSendNotification);
if (device != nullptr && device->instance != nullptr && device->get_device_status() >= DeviceStatus::Open) {
ui_device_sample_rate.setText(String(device->instance->sample_rate, 0), dontSendNotification);
ui_device_sample_type.setText(device->instance->sample_type == ASIOSTInt32LSB ? "Int32" : "Float32", dontSendNotification);
ui_device_in_channels.setText("In: " + String(device->instance->input_channels_number), dontSendNotification);
ui_device_out_channels.setText("Out: " + String(device->instance->output_channels_number), dontSendNotification);
}
else {
ui_device_sample_rate.setText("-", dontSendNotification);
Expand Down Expand Up @@ -204,8 +204,8 @@ void MainComponent::resized() {

int MainComponent::drawChannels(int x, int y, int w, int h) {
int height = 0;
if (device != nullptr && device->get_device_status() == DeviceStatus::Open) {
StringArray channel_names = device->get_input_channel_names();
if (device != nullptr && device->instance && device->get_device_status() == DeviceStatus::Open) {
StringArray channel_names = device->instance->input_channel_names;
int channels_count = channel_names.size();
if (channels_count > MAX_INPUT_CHANNELS) channels_count = MAX_INPUT_CHANNELS;
for (int i = 0; i < channels_count; i += 1) {
Expand Down Expand Up @@ -348,8 +348,8 @@ void MainComponent::buttonClicked(juce::Button* button) {
active_channels[channel_index] = false;
}

byte active_channels_count = 0;
if (device) active_channels_count = device->update_active_channels();
byte active_channels_number = 0;
if (device) active_channels_number = device->update_active_channels();
active_channel_indexes.sortNatural();
active_channels_string = active_channel_indexes.joinIntoString(",");
WriteSettings(ACTIVE_CHANNELS_INI_KEY, active_channels_string);
Expand All @@ -359,7 +359,7 @@ void MainComponent::buttonClicked(juce::Button* button) {
ui_writer_start_button.setEnabled(true);
ui_writer_stop_button.setEnabled(false);

writer->init(0, active_channels_count);
writer->init(0, active_channels_number);

for (int i = 0; i < MAX_INPUT_CHANNELS; i += 1) {
volumeter[i].setBounds(325, 120 + 30 * i, 0, 20);
Expand Down
46 changes: 0 additions & 46 deletions Source/asio/asiolist.h

This file was deleted.

Loading

0 comments on commit 6ecd1c4

Please sign in to comment.