diff --git a/espmusicmouse/.vscode/extensions.json b/espmusicmouse/.vscode/extensions.json index 0f0d740..080e70d 100644 --- a/espmusicmouse/.vscode/extensions.json +++ b/espmusicmouse/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/espmusicmouse/host_driver/music/.gitignore b/espmusicmouse/host_driver/music/.gitignore new file mode 100644 index 0000000..5628ebb --- /dev/null +++ b/espmusicmouse/host_driver/music/.gitignore @@ -0,0 +1 @@ +**/*.mp3 diff --git a/pyaudioplayeralsa/src/WavFile.cpp b/espmusicmouse/host_driver/music/config.yaml similarity index 100% rename from pyaudioplayeralsa/src/WavFile.cpp rename to espmusicmouse/host_driver/music/config.yaml diff --git a/figures_raw/Ducky.stl b/figures_raw/Ducky.stl new file mode 100644 index 0000000..4455512 Binary files /dev/null and b/figures_raw/Ducky.stl differ diff --git a/figures_raw/Elephant.stl b/figures_raw/Elephant.stl new file mode 100644 index 0000000..f87f0fa Binary files /dev/null and b/figures_raw/Elephant.stl differ diff --git a/figures_raw/Fox.stl b/figures_raw/Fox.stl new file mode 100644 index 0000000..0da2ba4 Binary files /dev/null and b/figures_raw/Fox.stl differ diff --git a/figures_raw/Meeple_-_Spielfigur.stl b/figures_raw/Meeple_-_Spielfigur.stl new file mode 100644 index 0000000..312cf0e Binary files /dev/null and b/figures_raw/Meeple_-_Spielfigur.stl differ diff --git a/figures_raw/omnom_60mm.stl b/figures_raw/omnom_60mm.stl new file mode 100644 index 0000000..696321d Binary files /dev/null and b/figures_raw/omnom_60mm.stl differ diff --git a/figures_raw/owl-print.stl b/figures_raw/owl-print.stl new file mode 100644 index 0000000..6d50da0 Binary files /dev/null and b/figures_raw/owl-print.stl differ diff --git a/figures_raw/puppy.stl b/figures_raw/puppy.stl new file mode 100644 index 0000000..2fb37e9 Binary files /dev/null and b/figures_raw/puppy.stl differ diff --git a/figures_raw/snowman.stl b/figures_raw/snowman.stl new file mode 100644 index 0000000..6c60cac Binary files /dev/null and b/figures_raw/snowman.stl differ diff --git a/figures_raw/squirrel.stl b/figures_raw/squirrel.stl new file mode 100644 index 0000000..f1f59f9 Binary files /dev/null and b/figures_raw/squirrel.stl differ diff --git a/musicmouse.FCStd b/musicmouse.FCStd index 50a62d8..0aa88e6 100644 Binary files a/musicmouse.FCStd and b/musicmouse.FCStd differ diff --git a/pyaudioplayeralsa/CMakeLists.txt b/pyaudioplayeralsa/CMakeLists.txt deleted file mode 100644 index 25c16c4..0000000 --- a/pyaudioplayeralsa/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project("pyaudioplayeralsa") - -add_executable(play main.cpp src/WavFile.cpp) -target_link_libraries(play -lasound -pthread) \ No newline at end of file diff --git a/pyaudioplayeralsa/main.cpp b/pyaudioplayeralsa/main.cpp deleted file mode 100644 index e7dd9e4..0000000 --- a/pyaudioplayeralsa/main.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Simple sound playback using ALSA API and libasound. - * - * Compile: - * $ cc -o play sound_playback.c -lasound - * - * Usage: - * $ ./play < - * - * Examples: - * $ ./play 44100 2 5 < /dev/urandom - * $ ./play 22050 1 8 < /path/to/file.wav - * - * Copyright (C) 2009 Alessandro Ghedini - * -------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * Alessandro Ghedini wrote this file. As long as you retain this - * notice you can do whatever you want with this stuff. If we - * meet some day, and you think this stuff is worth it, you can - * buy me a beer in return. - * -------------------------------------------------------------- - */ - -#include -#include - -#include - -#include "src/WavFile.h" - -#include -#include -#include -#include - -#define PCM_DEVICE "default" - -std::deque queue; -std::mutex queueMutex; - -static std::string getInput() -{ - - std::cout << "starting input thread" << std::endl; - while (true) - { - std::string result; - std::getline(std::cin, result); - { - std::lock_guard guard(queueMutex); - std::cout << "adding to queue" << std::endl; - queue.push_back(result); - } - } -} - -int main(int argc, char **argv) -{ - std::ifstream wavFileStream("test.wav", std::ios::binary); - WavFile wav(wavFileStream); - wavFileStream.close(); - std::cout << "Wav samples " << wav.size() << std::endl; - - unsigned int pcm, tmp, dir; - snd_pcm_t *pcm_handle; - snd_pcm_hw_params_t *params; - snd_pcm_uframes_t frames; - char *buff; - int buff_size, loops; - - /* Open the PCM device in playback mode */ - if (pcm = snd_pcm_open(&pcm_handle, PCM_DEVICE, - SND_PCM_STREAM_PLAYBACK, 0) < 0) - printf("ERROR: Can't open \"%s\" PCM device. %s\n", - PCM_DEVICE, snd_strerror(pcm)); - - /* Allocate parameters object and fill it with default values*/ - snd_pcm_hw_params_alloca(¶ms); - - snd_pcm_hw_params_any(pcm_handle, params); - - /* Set parameters */ - if (pcm = snd_pcm_hw_params_set_access(pcm_handle, params, - SND_PCM_ACCESS_RW_INTERLEAVED) < 0) - printf("ERROR: Can't set interleaved mode. %s\n", snd_strerror(pcm)); - - if (pcm = snd_pcm_hw_params_set_format(pcm_handle, params, - SND_PCM_FORMAT_S16_LE) < 0) - printf("ERROR: Can't set format. %s\n", snd_strerror(pcm)); - - if (pcm = snd_pcm_hw_params_set_channels(pcm_handle, params, wav.channels()) < 0) - printf("ERROR: Can't set channels number. %s\n", snd_strerror(pcm)); - - snd_pcm_hw_params_set_buffer_size(pcm_handle, params, 2 * 2048); - - unsigned int rate = wav.sampleRate(); - if (pcm = snd_pcm_hw_params_set_rate_near(pcm_handle, params, &rate, 0) < 0) - printf("ERROR: Can't set rate. %s\n", snd_strerror(pcm)); - - /* Write parameters */ - if (pcm = snd_pcm_hw_params(pcm_handle, params) < 0) - printf("ERROR: Can't set harware parameters. %s\n", snd_strerror(pcm)); - - /* Resume information */ - printf("PCM name: '%s'\n", snd_pcm_name(pcm_handle)); - - printf("PCM state: %s\n", snd_pcm_state_name(snd_pcm_state(pcm_handle))); - - snd_pcm_hw_params_get_channels(params, &tmp); - - printf("channels: %i ", tmp); - - if (tmp == 1) - printf("(mono)\n"); - else if (tmp == 2) - printf("(stereo)\n"); - - snd_pcm_hw_params_get_rate(params, &tmp, 0); - printf("rate: %d bps\n", tmp); - - /* Allocate buffer to hold single period */ - snd_pcm_hw_params_get_period_size(params, &frames, 0); - - buff_size = frames * wav.channels() * 2 /* 2 -> sample size */; - buff = (char *)malloc(buff_size); - std::cout << "Buffer size " << buff_size << " frames " << frames << std::endl; - - snd_pcm_hw_params_get_period_time(params, &tmp, NULL); - - std::thread inputThread(getInput); - bool playing = true; - - size_t wavFilePosition = 0; - while (wavFilePosition < wav.size()) - { - { - std::lock_guard guard(queueMutex); - if (queue.size() > 0) - { - queue.pop_back(); - std::cout << "Toggling" << std::endl; - //snd_pcm_drain(pcm_handle); - std::cout << "Done" << std::endl; - playing = !playing; - if (playing) - { - std::cout << "continuing at " << wavFilePosition << std::endl; - snd_pcm_pause(pcm_handle, 0); - //snd_pcm_prepare(pcm_handle); - } - else - snd_pcm_pause(pcm_handle, 1); - } - } - - if (!playing) - continue; - size_t dataToWrite = std::min(size_t(buff_size), wav.size() - wavFilePosition); - int framesToWrite = dataToWrite / wav.channels() / 2; - if (pcm = snd_pcm_writei(pcm_handle, wav[wavFilePosition], framesToWrite) == -EPIPE) - { - std::cout << "XRUN at wav position " << wavFilePosition << std::endl; - snd_pcm_prepare(pcm_handle); - } - else if (pcm < 0) - printf("ERROR. Can't write to PCM device. %s\n", snd_strerror(pcm)); - - wavFilePosition += dataToWrite; - } - - std::cout << "done filling buffer" << std::endl; - snd_pcm_drain(pcm_handle); - snd_pcm_close(pcm_handle); - free(buff); - - return 0; -} \ No newline at end of file diff --git a/pyaudioplayeralsa/plan.md b/pyaudioplayeralsa/plan.md deleted file mode 100644 index 7bf203a..0000000 --- a/pyaudioplayeralsa/plan.md +++ /dev/null @@ -1,5 +0,0 @@ -- play wav file [ok] - - read & parse wav file [ok] -- stop wave file in the middle, wait 2 secs and continue -- fade in/out -- mix second wave file on top (some effect) diff --git a/pyaudioplayeralsa/src/WavFile.h b/pyaudioplayeralsa/src/WavFile.h deleted file mode 100644 index 40f03a7..0000000 --- a/pyaudioplayeralsa/src/WavFile.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include -#include - -template -std::string readStr(std::istream &str) -{ - char buff[len]; - str.read(buff, len); - return std::string(buff, len); -} - -template -T read(std::istream &str) -{ - T res; - str.read((char *)&res, sizeof(res)); - return res; -} - -class WavFile -{ -public: - WavFile(std::istream &str) - { - auto chunkId = readStr<4>(str); - auto chunkSize = read(str); - auto format = readStr<4>(str); - - auto subchunk1Id = readStr<4>(str); - auto subchunk1Size = read(str); - - auto audioFormat = read(str); - numChannels_ = read(str); - sampleRate_ = read(str); - auto byteRate = read(str); - - auto blockAlign = read(str); - bitsPerSample_ = read(str); - - auto subchunk2Id = readStr<4>(str); - dataSize_ = read(str); - - data_ = std::unique_ptr(new char[dataSize_]); - str.read(data_.get(), dataSize_); - } - - uint32_t sampleRate() const { return sampleRate_; } - uint16_t channels() const { return numChannels_; } - uint32_t size() const { return dataSize_; } - - const char *operator[](int offset) const { return &data_.get()[offset]; } - -private: - std::unique_ptr data_; - uint32_t sampleRate_; - uint16_t bitsPerSample_; - uint32_t dataSize_; - uint16_t numChannels_; -}; \ No newline at end of file