Skip to content

Instantly share code, notes, and snippets.

@lucasw
Last active October 2, 2018 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasw/574e325be0c4ccf7112e3d8f68caa954 to your computer and use it in GitHub Desktop.
Save lucasw/574e325be0c4ccf7112e3d8f68caa954 to your computer and use it in GitHub Desktop.

Inspiration:

Doom 2016 Music:

https://www.youtube.com/watch?v=U4FNBMZsqrY

https://www.youtube.com/watch?v=Jm932Sqwf5E&t=4516s

Physical Sound

Tao stringed instrument simulation

http://taopm.sourceforge.net/examples/sounds.html

(uploaded to github https://github.com/MindBuffer/tao - did they import version history? It doesn't look like it.)

Could convert to CMake.

sudo apt install libaudiofile-dev
cd tao
make distclean  # build artifacts were checked into source
cd ..
mkdir build_tao
cd build_tao
../tao/configure --prefix=$HOME/other/install
make
../../tao/libtao/Tao.cc: In member function 'void Tao::main(int, char**)':
../../tao/libtao/Tao.cc:156:14: error: 'EOF' was not declared in this scope
  if (option==EOF) break;

-> https://github.com/lucasw/tao build_ubuntu branch makes it build, but can't get examples to work:

Syntax error: Bad fd number

The contents of include didn't get installed, copy them to $HOME/other/install/include/tao manually

mkdir $HOME/other/install/include/tao
cp include/*.h /home/lucasw/other/install/include/tao

taoparse looks to have worked fine and generates a .cc file, just need to compile it. The tao script could easily be replaced.

taoparse test.tao > test.cc
g++ -O2 -I$HOME/other/install/include/tao -L$HOME/other/install/lib -DSCRIPTNAME=test.cc -o test.exe test.cc -ltao -lX11 -lXmu -lXi -lGL -lGLU -lpthread -lglut -lm

Lambda FDTD

https://github.com/gesellkammer/lambda

Python

Play sound in python.

Other

Din is Noise

Ardour?

@lucasw
Copy link
Author

lucasw commented Sep 22, 2018

Going to try out lambda (what is it with the impossible to google names?), also look at http://www.openpstd.org/
https://github.com/openPSTD/openPSTD .

lambda

cd lambda/src
/usr/lib/qt5/bin/qmake lambda.pro
make
...
lambda.h:25:10: fatal error: QApplication: No such file or directory
 #include <QApplication>

Add /usr/include/x86_64-linux-gnu/qt5/QtWidgets to lambda.pro include dirs.

Next

g++ -Wl,-O1 -o Lambda lambda.o main.o moc_lambda.o   -L. -lrevel -lxvidcore -lX11 -L/opt/X11/lib -L/opt/local/lib -lQt5Gui -lQt5Core -lGL -lpthread 
/usr/bin/x86_64-linux-gnu-ld: cannot find -lrevel
/usr/bin/x86_64-linux-gnu-ld: cannot find -lxvidcore
collect2: error: ld returned 1 exit status
sudo apt install libxvidcore-dev

revel

Need to go into dependencies and build revel 1.2.0.

Many of the build files in revel-1.2.0 are symlinks, probably locations on the harddrive of whoever pushed this.

Try deleting them and replacing them with copies from revel-1.1.0 tree.

$ make
CDPATH="${ZSH_VERSION+.}:" && cd . && aclocal-1.14 
/bin/bash: aclocal-1.14: command not found
Makefile:345: recipe for target 'aclocal.m4' failed
make: *** [aclocal.m4] Error 127

Change 1.14 to 1.15 in configure.

CDPATH="${ZSH_VERSION+.}:" && cd . && aclocal-1.15 
configure.ac:27: warning: macro 'AM_PATH_XVID' not found in library
 cd . && automake-1.15 --gnu
configure.ac:3: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.ac:3: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:5: error: required file './compile' not found
configure.ac:5:   'automake --add-missing' can install 'compile'
Makefile.am: error: required file './INSTALL' not found
Makefile.am:   'automake --add-missing' can install 'INSTALL'

Maybe can just comment out usage of this library?
No need for integrate video encoding.

Need Qt5Widgets library.

@lucasw
Copy link
Author

lucasw commented Sep 22, 2018

lambda_synth

Ran a simulation but don't see anything happening- do sound signals get injected separately?

Ran example.sim and there is a source in the middle, but no walls, it ends before any edges are reached.

Need to set the iterations to 0, which is infinite.

@lucasw
Copy link
Author

lucasw commented Sep 22, 2018

https://github.com/lucasw/lambda/tree/ubuntu_1804

Install:

cp Lambda ~/other/install/bin/

Next try https://github.com/gesellkammer/lambdasim

Adapting lambda

There is one big lambda.cpp file with everything in it, could extract just the necessary functions:

  • adaptfilter()
  • adaptreflexionfactor()
  • processSim() - there is a lot of special case code for various signal sources, probably want to eliminate that and only support samples unless there is something better about the special case sine wave vs. a sampled one.
  • initSimulation() - a lot of the arrays and dynamic memory ought to be updated.
  • loadSimulation() - this needs the most adapting, want everything it does to be done differently.
  • defineSource()
  • set() some parts of this may be needed
  • resetAll()
  • initVariables()

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

OpenPSTD

Ubuntu 18.04

fatal error: Eigen/Core: No such file or directory
 #include <Eigen/Core>

It's in /usr/include/eigen3/Eigen/Core so it isn't getting found properly.

build_openpstd$ cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3
openPSTD/kernel/DG/Jacobi.h:152:26: error: ‘vector’ is not a member of ‘std’

openPSTD/openPSTD#130

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

[ 16%] Building CXX object CMakeFiles/OpenPSTD.dir/kernel/DG/LEE.cpp.o
In file included from /usr/include/eigen3/Eigen/Core:347:0,
                 from /usr/include/eigen3/Eigen/Dense:1,
                 from /home/lucasw/own/github/sound/openPSTD/kernel/DG/LEE.h:35,
                 from /home/lucasw/own/github/sound/openPSTD/kernel/DG/LEE.cpp:32:
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h: In instantiation of ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<float, -1, 1>; Src = Eigen::CwiseUnaryOp<OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]::<lambda(float)>, const Eigen::Matrix<float, -1, 1> >; Func = Eigen::internal::assign_op<float, double>]’:
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:804:27:   required from ‘void Eigen::internal::call_assignment(Dst&, const Src&, const Func&, typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type) [with Dst = Eigen::Matrix<float, -1, 1>; Src = Eigen::CwiseUnaryOp<OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]::<lambda(float)>, const Eigen::Matrix<float, -1, 1> >; Func = Eigen::internal::assign_op<float, double>; typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type = void*]’
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:782:18:   required from ‘void Eigen::internal::call_assignment(Dst&, const Src&) [with Dst = Eigen::Matrix<float, -1, 1>; Src = Eigen::CwiseUnaryOp<OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]::<lambda(float)>, const Eigen::Matrix<float, -1, 1> >]’
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:710:32:   required from ‘Derived& Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]::<lambda(float)>, const Eigen::Matrix<float, -1, 1> >; Derived = Eigen::Matrix<float, -1, 1>]’
/usr/include/eigen3/Eigen/src/Core/Matrix.h:225:24:   required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]::<lambda(float)>, const Eigen::Matrix<float, -1, 1> >; _Scalar = float; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1]’
/home/lucasw/own/github/sound/openPSTD/kernel/DG/LEE.h:147:40:   required from ‘void OpenPSTD::Kernel::DG::LinearizedEulerEquationsDE<SimpleType>::Initialize(std::shared_ptr<OpenPSTD::Kernel::DG::Element1D<SimpleType> >) [with SimpleType = float]’
/home/lucasw/own/github/sound/openPSTD/kernel/DG/LEE.cpp:36:16:   required from here
/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32:40: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
     #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
                                        ^
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:816:3: note: in expansion of macro ‘EIGEN_STATIC_ASSERT’
   EIGEN_STATIC_ASSERT((Eigen::internal::has_ReturnType<ScalarBinaryOpTraits<LHS, RHS,BINOP> >::value), \
   ^~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:834:3: note: in expansion of macro ‘EIGEN_CHECK_BINARY_COMPATIBILIY’
   EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/OpenPSTD.dir/build.make:542: recipe for target 'CMakeFiles/OpenPSTD.dir/kernel/DG/LEE.cpp.o' failed

Commenting out all the templates that cause this- they all seem to be <float> types that aren't used anywhere in the code (but maybe other code uses them within a library?).

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

hdf5.h isn't found, so:

cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3 -DHDF5_INCLUDE=/usr/include/hdf5/openmpi
In file included from /usr/include/hdf5/openmpi/hdf5.h:24:0,
                 from /home/lucasw/own/github/sound/openPSTD/shared/export/HDF5Export.cpp:8:
/usr/include/hdf5/openmpi/H5public.h:61:13: fatal error: mpi.h: No such file or directory
 #   include <mpi.h>

There is also a hdf5/serial directory with hdf5.h in it.

cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3 -DHDF5_INCLUDE=/usr/include/hdf5/serial
[ 30%] Linking CXX executable OpenPSTD-cli
libOpenPSTD.so: undefined reference to `fftwf_destroy_plan'
libOpenPSTD-shared.so: undefined reference to `H5Fcreate'
libOpenPSTD.so: undefined reference to `fftwf_free'
libOpenPSTD.so: undefined reference to `Eigen::Matrix<float, -1, 1, 0, -1, 1> OpenPSTD::Kernel::DG::Simplex2DP<float>(Eigen::Array<float, -1, -1, 0, -1, -1>, int, int)'
libOpenPSTD-shared.so: undefined reference to `H5check_version'
libOpenPSTD.so: undefined reference to `fftwf_plan_many_dft_r2c'
libOpenPSTD.so: undefined reference to `OpenPSTD::Kernel::DG::GradSimplex2DPResult<float> OpenPSTD::Kernel::DG::GradSimplex2DP<float>(Eigen::Array<float, -1, -1, 0, -1, -1>, int, int)'
libOpenPSTD.so: undefined reference to `fftwf_execute_dft_r2c'
libOpenPSTD-shared.so: undefined reference to `H5open'
libOpenPSTD-shared.so: undefined reference to `H5T_NATIVE_FLOAT_g'
libOpenPSTD.so: undefined reference to `fftwf_execute_dft_c2r'
libOpenPSTD-shared.so: undefined reference to `H5Fclose'
libOpenPSTD-shared.so: undefined reference to `H5Gclose'
libOpenPSTD-shared.so: undefined reference to `H5Gcreate2'
libOpenPSTD.so: undefined reference to `Eigen::Array<float, -1, 1, 0, -1, 1> OpenPSTD::Kernel::DG::WarpFactor<float>(int, Eigen::Matrix<float, -1, 1, 0, -1, 1>)'
libOpenPSTD.so: undefined reference to `fftwf_malloc'
libOpenPSTD.so: undefined reference to `fftwf_plan_many_dft_c2r'
libOpenPSTD-shared.so: undefined reference to `H5LTmake_dataset'
collect2: error: ld returned 1 exit status

cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3 -DHDF5_INCLUDE=/usr/include/hdf5/serial -DHDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -DFFTWF_LIBRARY=/usr/lib/x86_64-linux-gnu/libfftw3f.so

But now the consequences of removing the eigen matrices is seen:

libOpenPSTD.so: undefined reference to `Eigen::Matrix<float, -1, 1, 0, -1, 1> OpenPSTD::Kernel::DG::Simplex2DP<float>(Eigen::Array<float, -1, -1, 0, -1, -1>, int, int)'
libOpenPSTD.so: undefined reference to `OpenPSTD::Kernel::DG::GradSimplex2DPResult<float> OpenPSTD::Kernel::DG::GradSimplex2DP<float>(Eigen::Array<float, -1, -1, 0, -1, -1>, int, int)'
libOpenPSTD.so: undefined reference to `Eigen::Array<float, -1, 1, 0, -1, 1> OpenPSTD::Kernel::DG::WarpFactor<float>(int, Eigen::Matrix<float, -1, 1, 0, -1, 1>)'
libOpenPSTD-shared.so: undefined reference to `H5LTmake_dataset'

Also H5LTmake_dataset?

$ cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3 -DHDF5_INCLUDE=/usr/include/hdf5/serial -DHDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -DHDF5_HL_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so  -DFFTWF_LIBRARY=/usr/lib/x86_64-linux-gnu/libfftw3f.so

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

https://github.com/micfort/openDG is many commits ahead (and renamed, has own issues)- possibly all related to a 'DG' kernel.
https://github.com/Louisvh/openPSTD is 18 commits ahead - these look all related to the build system, travis.

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

18.04 is using eigen 3.3.4-4, while pstd wants 3.2.6.
Download and use that version.

Now it builds successfully.

Ran ./openPSTD-gui, made new scene, ran simulation.
The view doesn't update to show latest frame, need to keep scrolling to right.

Seems slower that the FTDT application but maybe is more accurate, can do diagonal walls or walls with various physical properties better?

screenshot from 2018-09-29 13-15-01

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

Export frames doesn't prepend zeros, so test-1.jpg test-2.jpg .. test-20.jpg so they don't sort properly.

Don't see anything in exported images.

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

How to get microphone output out?

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

The pstd saved files does save all the rendered frames. 600 frames -> 32 MB.

@lucasw
Copy link
Author

lucasw commented Sep 29, 2018

Some of the branches on the official github are much more recent.

Probably should try 3.0 (most recently updated) or 3.1.

3.0 build with qmake but takes 100% cpu doing nothing but drawing the ui.

Tried to run simulation:

sh: 1: OpenPSTD-cli.exe: not found
Floating point exception (core dumped)

@lucasw
Copy link
Author

lucasw commented Sep 30, 2018

OpenPSTD 2.0 master branch

Same as the screenshot above.

Most attempts to change from default room then simulate result in crash:

=Viewer2D:: this->layers[4]->PaintGL
1281: invalid value
OpenPSTD-gui: /home/lucasw/own/github/sound/build_openPSTD/eigen/eigen/Eigen/src/Core/CwiseNullaryOp.h:63: Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::CwiseNullaryOp(Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::Index, Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::Index, const NullaryOp&) [with NullaryOp = Eigen::internal::scalar_constant_op<float>; PlainObjectType = Eigen::Array<float, -1, -1>; Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::Index = long int]: Assertion `nbRows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == nbRows) && nbCols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == nbCols)' failed.
Aborted (core dumped)

Try the openDG fork.

@lucasw
Copy link
Author

lucasw commented Sep 30, 2018

OpenDG (OpenPSTD 2.0 fork)

$ cmake ../openPSTD/ -DEIGEN_INCLUDE=/usr/include/eigen3 -DHDF5_INCLUDE=/usr/include/hdf5/serial -DHDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -DHDF5_HL_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so  -DFFTWF_LIBRARY=/usr/lib/x86_64-linux-gnu/libfftw3f.so

The eigen error is fixed there either, so use eigen 3.2.6

cmake ../openDG/ -DEIGEN_INCLUDE=../eigen -DHDF5_INCLUDE=/usr/include/hdf5/serial -DHDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -DHDF5_HL_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so  -DFFTWF_LIBRARY=/usr/lib/x86_64-linux-gnu/libfftw3f.s

It also crashes if any domains are added to the room.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment