Code Monkey home page Code Monkey logo

Comments (5)

igorski avatar igorski commented on August 30, 2024 1

Hi @KoertGaaikema I will close this issue as the original one has been resolved. If you can send me a message via the form on https://igorski.nl/contact we can have a look at your pitch shifting question :)

from mwengine.

igorski avatar igorski commented on August 30, 2024

Hi @KoertGaaikema , have you tried the introduction on sample based content in the Wiki: https://github.com/igorski/MWEngine/wiki/Example-:-Creating-a-simple-drum-machine ? What you need is an instance of SampledInstrument that can play back samples that are registered inside the SampleManager.

I am tempted to extend the example Activity in this repository though as I can see the benefit of including an example on working with sample based sequencing. Would you agree that adding a simple kick/snare pattern to the existing demo Activity could be of help ?

from mwengine.

KoertGaaikema avatar KoertGaaikema commented on August 30, 2024

Yes, I've got all of that set up !

And did read most of the wiki already :D

At the start of my app I copy all audio files to the local filesystem of my phone now , and load them from there ( not the nicest solution, but at least I can get to the files via JavaUtilities.createSampleFromFile )
The main error I get now is "WaveReader::Error not a valid WAVE file (no RIFF header)"
And I'm pretty sure it's a valid wav file ( I use the same files in a IOS app )

But I prefer to just load them from the assets folder directly.

It would be really helpful to add a working example indeed where you actually load wav files.
Much appreciated!

I'm purely working with the java side of the repo btw, since c++ is new to me ;)

Btw, to make the thing compile I had to add "-latomic" to line 81 of Android.mk

LOCAL_LDLIBS := -llog -lOpenSLES -latomic

Not sure if it only applies to my machine / setup though ...

K.

from mwengine.

igorski avatar igorski commented on August 30, 2024

Hello again!

I understand the issue. Depending on how you copied your resources it is possible the files aren't actual WAV files when they are copied onto the local filesystem as assets are compressed when packaged inside an .APK (unless you add them as a resource to the /res/raw folder).

However, it is obviously not ideal to have to copy your package contents onto the filesystem (and worry about the decompression as well). For this purpose, I have created a new function in JavaUtilities called createSampleFromAsset. This method allows you to pass the String name of the asset which will then be loaded directly from the APK's /assets folder (making it possible to use compression for your assets, which is nice, but also to not have to temporarily store data on the device's file system, which is even nicer).

This development is currently on this feature branch: https://github.com/igorski/MWEngine/tree/samples (which will eventually be merged via #23 when some refactoring issues have been resolved).

You can check the branch out and view MWEngineActivity.java for an example on how to use the new createSampleFromAsset-method (lines 139 onwards). I hope this also addresses the issue you had with the corrupt WAV file (try replacing one of the .wav files in the repository's /assets/ folder with your file to see if the issue is resolved).

I have also added your "-latomic" addition to the make files, it is a requirement for the new NDK.

from mwengine.

KoertGaaikema avatar KoertGaaikema commented on August 30, 2024

Cool !

It works like a charm !
Really straight forward now.
Thanks !

I've got one more question ( maybe a few more when I dive into it :D ) .

Is it possible to change rate / pitch of a SampledInstrument ?
So I can use a simple wav as an actual instrument and play different notes ?

K.

from mwengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.