Skip to content

Commit

Permalink
Merge pull request #92 from kzantow/cumulative-fixes-and-zoomable-ui
Browse files Browse the repository at this point in the history
Cumulative fixes and zoomable ui
  • Loading branch information
kurasu authored Dec 18, 2018
2 parents 114de69 + 4df28c0 commit fa85b05
Show file tree
Hide file tree
Showing 58 changed files with 1,202 additions and 530 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ target/
*.pdb
packages.config

# XCode
Surge.xcworkspace/
surge-au.xcodeproj/
surge-vst2.xcodeproj/
surge-vst3.xcodeproj/
products/

# IntelliJ IDEA
.idea
.idea
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ It currently only builds on windows, but getting it to build on macOS again & Li

[Releases are available here](https://github.com/kurasu/surge/releases)

Discussion at KVR-Forum [here](https://www.kvraudio.com/forum/viewtopic.php?f=1&t=511922)
Development Discussion at KVR-Forum [here](https://www.kvraudio.com/forum/viewtopic.php?f=33&t=511921)

## Preparation

First you need to grab all git submodules (needed to get the VST3 SDK)
Expand Down Expand Up @@ -140,4 +137,5 @@ An example of setting the environment variable `VST2SDK_DIR` would be:

## References

* IRC channel #surgesynth @ irc.freenode.net
* Discussion at KVR-Forum [here](https://www.kvraudio.com/forum/viewtopic.php?f=1&t=511922)
* IRC channel #surgesynth @ irc.freenode.net
7 changes: 6 additions & 1 deletion build-osx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh
premake5 xcode4
xcodebuild build -configuration Release -project surge-vst2.xcodeproj
if [ -n "$VST2SDK_DIR" ]; then
xcodebuild clean -project surge-vst2.xcodeproj
xcodebuild build -configuration Release -project surge-vst2.xcodeproj
fi
xcodebuild clean -project surge-vst3.xcodeproj
xcodebuild build -configuration Release -project surge-vst3.xcodeproj
xcodebuild clean -project surge-au.xcodeproj
xcodebuild build -configuration Release -project surge-au.xcodeproj
175 changes: 126 additions & 49 deletions libs/filesystem/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,67 @@
#include "filesystem.h"

namespace std::experimental::filesystem {
path::path():
path("")
{}

path::path(std::string filePath):
p(filePath)
{}

path::operator std::string() {
return p;
}

void path::append(std::string s) {
p.append("/");
p.append(s);
}

const char* path::c_str() {
return p.c_str();
}

std::string path::generic_string() {
return p;
}

path path::filename() {
auto idx = this->p.find_last_of("/");
path p(this->p.substr(idx+1));
return p;
}

std::string path::extension() {
auto idx = this->p.find_last_of(".");
return p.substr(idx);
}
// path class:
path::path():
path("")
{}

file::file(std::string filePath):
p(filePath)
{}

file::operator class path() {
return p;
}

path file::path() {
return p;
}
path::path(std::string filePath):
p(filePath)
{}

path::operator std::string() {
return p;
}

void path::append(std::string s) {
p.append("/");
p.append(s);
}

const char* path::c_str() {
return p.c_str();
}

std::string path::generic_string() const {
return p;
}

path path::filename() {
auto idx = this->p.find_last_of("/");
path p(this->p.substr(idx+1));
return p;
}

std::string path::extension() {
auto idx = this->p.find_last_of(".");
return p.substr(idx);
}
// emd path class

// file class:
file::file(std::string filePath):
p(filePath)
{}

file::operator class path() {
return p;
}

path file::path() const {
return p;
}
// end file class

// directory_entry class:
directory_entry::directory_entry(class path p):
p(p)
{}

path directory_entry::path() const {
return p;
}
// end directory_entry

bool exists(path p) {
FILE *file;
Expand Down Expand Up @@ -107,9 +121,13 @@ namespace std::experimental::filesystem {

// this needs to return the full path not just the relative path
while ((dirp = readdir(dp)) != NULL) {
path newp = p;
newp.append( dirp->d_name );
file res( newp.c_str() );
string fname(dirp->d_name);
// Skip . and .. : https://github.com/kurasu/surge/issues/77
if (fname.compare(".") == 0 || fname.compare("..") == 0) {
continue;
}

file res(p.generic_string() + '/' + fname);

files.push_back(res);
}
Expand All @@ -118,6 +136,65 @@ namespace std::experimental::filesystem {

return files;
}

std::vector<directory_entry> recursive_directory_iterator(const path& src) {
std::vector<directory_entry> entries;
for(const auto& entry : directory_iterator(src)) {
const auto& p = entry.path();
directory_entry e(p);
entries.emplace_back(e);
if (is_directory(p)) {
std::vector<directory_entry> subdir = recursive_directory_iterator(p);
for(const auto& subdirEntry : subdir) {
entries.emplace_back(subdirEntry);
}
}
}
return entries;
}

path relative(const path& p, const path& root) {
return path(p.generic_string().substr(root.generic_string().length()));
}

void copy(const path& src, const path& dst, const copy_options options) {
std::ifstream in(src.generic_string());
std::ofstream out(dst.generic_string());
out << in.rdbuf();
}

void copy_recursive(const path& src, const path& target, const std::function<bool(path)>& predicate) noexcept
{
try
{
for (const auto& dirEntry : recursive_directory_iterator(src))
{
const auto& p = dirEntry.path();
if (predicate(p))
{
// Create path in target, if not existing.
const auto relativeSrc = relative(p, src);
auto targetStr = target.generic_string() + '/' + relativeSrc.generic_string();
path targetPath(targetStr);
if (is_directory(p)) {
create_directories(targetPath);
} else {
// Copy to the targetParentPath which we just created.
copy(p, targetPath, copy_options::overwrite_existing);
}
}
}
}
catch (std::exception& e)
{
// std::cout << e.what();
}
}

void copy_recursive(const path& src, const path& target) noexcept
{
copy_recursive(src, target, [](path p) { return true; });
}
}

#endif
Expand Down
31 changes: 29 additions & 2 deletions libs/filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#ifndef Filesystem_h
#define Filesystem_h

#include <functional>

#ifdef __APPLE__
#include "TargetConditionals.h"
#ifdef TARGET_OS_MAC
Expand All @@ -17,6 +19,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fstream>

namespace std::experimental::filesystem {
class path {
Expand All @@ -33,7 +36,7 @@ namespace std::experimental::filesystem {

const char* c_str();

std::string generic_string();
std::string generic_string() const;

path filename();

Expand All @@ -48,7 +51,16 @@ namespace std::experimental::filesystem {

operator path();

path path();
path path() const;
};

class directory_entry {
public:
path p;

directory_entry(path p);

path path() const;
};

bool exists(path p);
Expand All @@ -58,6 +70,21 @@ namespace std::experimental::filesystem {
bool is_directory(path p);

std::vector<file> directory_iterator(path p);

std::vector<directory_entry> recursive_directory_iterator(const path& src);

path relative(const path& p, const path& root);

enum copy_options {
overwrite_existing = 1
};

void copy(const path& src, const path& dst, const copy_options options);

// Exras:
void copy_recursive(const path& src, const path& target, const std::function<bool(path)>& predicate) noexcept;

void copy_recursive(const path& src, const path& target) noexcept;
}

#endif
Expand Down
5 changes: 4 additions & 1 deletion package-au.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ PACKAGE_SRC_LOCATION="$RES_SRC_LOCATION/osx-au"
BITMAP_SRC_LOCATION="$RES_SRC_LOCATION/bitmaps"
BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/au/Release/Surge.dylib"
#EXEC_LOCATION="target/au/Debug/Surge-Debug.dylib"

# output configs
OUTPUT_DIR=products
BUNDLE_NAME="Surge.component"
BUNDLE_DIR="$OUTPUT_DIR/$BUNDLE_NAME"
EXEC_TARGET_NAME="Surge"

echo Creating VST Bundle...
echo "Creating AudioUnit (AU) Bundle..."

# create basic bundle structure

Expand All @@ -32,3 +33,5 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
mkdir -p "$BUNDLE_DIR/Contents/Data"
cp -rf resources/data "$BUNDLE_DIR/Contents/Data"
4 changes: 4 additions & 0 deletions package-vst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PACKAGE_SRC_LOCATION="$RES_SRC_LOCATION/osx-vst2"
BITMAP_SRC_LOCATION="$RES_SRC_LOCATION/bitmaps"
BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/vst2/Release/Surge.dylib"
#EXEC_LOCATION="target/vst2/Debug/Surge-Debug.dylib"

# output configs
OUTPUT_DIR=products
Expand All @@ -32,3 +33,6 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
mkdir -p "$BUNDLE_DIR/Contents/Data"
cp -rf resources/data "$BUNDLE_DIR/Contents/Data"

3 changes: 3 additions & 0 deletions package-vst3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
mkdir -p "$BUNDLE_DIR/Contents/Data"
cp -rf resources/data "$BUNDLE_DIR/Contents/Data"

Loading

0 comments on commit fa85b05

Please sign in to comment.