Skip to content

Commit

Permalink
v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dazaizer0 authored Nov 29, 2023
1 parent 20dd964 commit 051c02d
Show file tree
Hide file tree
Showing 44 changed files with 3,429 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CMakeList.txt: plik projektu CMake najwyższego poziomu, wykonaj konfigurację globalną
# i uwzględnij podprojekty w tym miejscu.
#
cmake_minimum_required (VERSION 3.8)

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("beep_engine")

# Uwzględnij podprojekty.
add_subdirectory ("beep_engine")
101 changes: 101 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
},
{
"name": "macos-debug",
"displayName": "macOS Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
}
]
}
12 changes: 12 additions & 0 deletions beep_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# CMakeList.txt: projekt CMake dla elementu beep_engine, dołącz źródło i zdefiniuj
# tutaj logikę specyficzną dla projektu.
#

# Dodaj źródło do pliku wykonywalnego tego projektu.
add_executable (beep_engine "beep_engine.cpp" "Headers/beep_libs.h" "Headers/beep_variables.h" "Headers/beep.h")

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET beep_engine PROPERTY CXX_STANDARD 20)
endif()

# TODO: Dodaj testy i zainstaluj elementy docelowe w razie potrzeby.
4 changes: 4 additions & 0 deletions beep_engine/Headers/beep.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "beep_libs.h"

// VERSION v1.1.1
const std::string beep_engie1 = "made by dazaizer0";
63 changes: 63 additions & 0 deletions beep_engine/Headers/beep_funcs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "beep_libs.h"


void PRINT(const std::string& message)
{
std::cout << message;
}

void PLAY(const double frequency, int duration)
{
const double period = 1.0 / frequency * 1000000; // T = 1 / f

#ifdef _WIN32
Beep(static_cast<int>(frequency), duration);
#else
for (int i = 0; i < duration * 1000; i += period)
{
std::cout << "\a"; // play sound
std::this_thread::sleep_for(std::chrono::microseconds(static_cast<int>(period)));
}
#endif
}

class SOUND
{
public:
SOUND() : frequency(0.0), duration(0) {} // default sound constructor
SOUND(const double f, const int d) : frequency(f), duration(d) {}

double getFrequency() const
{
return frequency;
}

int getDuration() const
{
return duration;
}

private:
double frequency;
int duration;
};

void PLAY_SOUNDS(const std::map<int, SOUND> SOUNDS, int base_sleep_time)
{
for (const auto& sound : SOUNDS)
{
PLAY(sound.second.getFrequency(), sound.second.getDuration());
std::cout << std::flush;

Sleep(base_sleep_time);
}
}

void CLEAR_TERMINAL()
{
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}
16 changes: 16 additions & 0 deletions beep_engine/Headers/beep_libs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <iostream>
#include <map>
#include <chrono>
#include <thread>
#include <conio.h>
#include <cstdlib>
#include <fstream>

#ifdef _WIN32
#include <Windows.h>
#include <windows.h>
#else
#include <unistd.h>
#endif
14 changes: 14 additions & 0 deletions beep_engine/Headers/beep_variables.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "beep_libs.h"


const std::string beepboard_hello_message = " <- base_frequency, This is beepboard[play = [f, g, h, j, k], tone_controls[+, -], quit[/]: ";
const std::string hello_message = "[1 - beep_map], [2 - beepboard], [3 - beeplist], [4 - quit], [5 - clear], [6 - change base values]: ";
const std::string program_message = "Welcome to beep_engine2023! The universal engine, created to generate beeps whatever platform you use: ";
const std::string beepmap_hello_message = "This is beepmap please type the length of your beep map: ";
const std::string beeplist_hello_message = "This is beeplist, [f, g, h, j, k], tone_controls[+, -], quit[/], [enter] to play:";

int base_frequency = 300;
int frequency_change = 100;
int beeps_frequency_change = 100;
int base_duration = 720;
int base_sleep_time = 0;
Loading

0 comments on commit 051c02d

Please sign in to comment.