CocoTeens7 - Hit The Tune: Difference between revisions

From SGMK-SSAM-WIKI
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 5: Line 5:
== Install guide ==
== Install guide ==


# Install arduino version 1.6.11 or lower (newer version are *not* yet supported): [https://www.arduino.cc/en/Main/OldSoftwareReleases#previous https://www.arduino.cc/en/Main/OldSoftwareReleases#previous]
# Install latest arduino version (currently 1.6.12) or lower: [https://www.arduino.cc/en/Main/OldSoftwareReleases#previous https://www.arduino.cc/en/Main/OldSoftwareReleases#previous]
# Install "teensyduino": [http://www.pjrc.com/teensy/td_download.html http://www.pjrc.com/teensy/td_download.html]
# Install "teensyduino": [http://www.pjrc.com/teensy/td_download.html http://www.pjrc.com/teensy/td_download.html]


Line 18: Line 18:
=== MIDI ===
=== MIDI ===


<syntaxhighlight lang="supercollider">
Example: [https://github.com/CocoMake7/CocoTeens7/blob/master/CocoTeensy_MIDI/CocoTeensy_MIDI.ino https://github.com/CocoMake7/CocoTeens7/blob/master/CocoTeensy_MIDI/CocoTeensy_MIDI.ino]
 
Supercollider test patch
 
<syntaxhighlight lang="python">


MIDIClient.init;
MIDIClient.init;
Line 24: Line 28:


(
(
p = ProxySpace.push(s.boot);
    p = ProxySpace.push(s.boot);
~mysound1.play();
    ~mysound1.play();
~mysound2.play();
    ~mysound2.play();
~mysound3.play();
    ~mysound3.play();
~mysound4.play();
    ~mysound4.play();
~mysound1 = { SinOsc.ar(\freq.kr(220)) * 0.2 };
    ~mysound1 = { SinOsc.ar(\freq.kr(220)) * 0.2 };
~mysound2 = { SinOsc.ar(\freq.kr(440)) * 0.2 };
    ~mysound2 = { SinOsc.ar(\freq.kr(440)) * 0.2 };
~mysound3 = { SinOsc.ar(\freq.kr(880)) * 0.2 };
    ~mysound3 = { SinOsc.ar(\freq.kr(880)) * 0.2 };
~mysound4 = { SinOsc.ar(\freq.kr(1760)) * 0.2 };
    ~mysound4 = { SinOsc.ar(\freq.kr(1760)) * 0.2 };
MIDIFunc.cc({arg ...args; ~mysound1.set(\freq, args[0]*10);}, 66, 0);
    MIDIFunc.cc({arg ...args; ~mysound1.set(\freq, args[0]*10);}, 66, 0);
MIDIFunc.cc({arg ...args; ~mysound2.set(\freq, args[0]*10);}, 77, 0);
    MIDIFunc.cc({arg ...args; ~mysound2.set(\freq, args[0]*10);}, 77, 0);
MIDIFunc.cc({arg ...args; ~mysound3.set(\freq, args[0]*10);}, 88, 0);
    MIDIFunc.cc({arg ...args; ~mysound3.set(\freq, args[0]*10);}, 88, 0);
MIDIFunc.cc({arg ...args; ~mysound4.set(\freq, args[0]*10);}, 99, 0);
    MIDIFunc.cc({arg ...args; ~mysound4.set(\freq, args[0]*10);}, 99, 0);
)
)
</syntaxhighlight>
</syntaxhighlight>


== Wav2Sketch ==
== Wav2Sketch ==
Line 46: Line 49:


More infos: [https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html]
More infos: [https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html]
=== compile the converter ===


MacOS and *nix users need to compile the sample conversion software "wav2sketch" from command line.
MacOS and *nix users need to compile the sample conversion software "wav2sketch" from command line.
Line 55: Line 60:


Copy&paste the makefile below to a file called "makefile" without file extension. Open a terminal in the directory, where "wav2sketch.c" and "makefile" is present and type "make". If no errors occured
Copy&paste the makefile below to a file called "makefile" without file extension. Open a terminal in the directory, where "wav2sketch.c" and "makefile" is present and type "make". If no errors occured
you should now have the program "wav2sketch" in the same directory. Audio samples can just be placed in the same directory as the program for conversion. In the terminal, type "./wav2sketch" to execute the
you should now have the program "wav2sketch" in the same directory.  
program. This should generate cpp/h files for all wav files present in the folder. As an option, uncompressed 16 bit samples can be generated by passing the option "-16" to the program.
 
=== convert wav files ===
 
WAV-Audio samples can just be placed in the same directory as the program for conversion. In the Terminal, if it points to the folder of your "wav2sketch" program already, type ./wav2sketch to execute the program. Otherwise you can just type the absolute path, for example "/Users/yourUserName/Desktop/Wavs/wav2sketch". This should generate cpp/h files for all wav files present in the folder.  
 
As an option, uncompressed 16 bit samples can be generated by passing the option "-16" to the program.
MacOS users need to install XCode environment, linux useres need gcc (should be installed anyway).
MacOS users need to install XCode environment, linux useres need gcc (should be installed anyway).


Makefile (for Mac OS/*nix users):
=== Makefile (for Mac OS/*nix users) ===


<syntaxhighlight lang="make">
<syntaxhighlight lang="make">

Latest revision as of 01:02, 18 November 2016

About

Install guide

  1. Install latest arduino version (currently 1.6.12) or lower: https://www.arduino.cc/en/Main/OldSoftwareReleases#previous
  2. Install "teensyduino": http://www.pjrc.com/teensy/td_download.html

Github

Code examples can be found on github

https://github.com/CocoMake7/CocoTeens7

Examples

MIDI

Example: https://github.com/CocoMake7/CocoTeens7/blob/master/CocoTeensy_MIDI/CocoTeensy_MIDI.ino

Supercollider test patch

MIDIClient.init;
MIDIIn.connectAll;

(
    p = ProxySpace.push(s.boot);
    ~mysound1.play();
    ~mysound2.play();
    ~mysound3.play();
    ~mysound4.play();
    ~mysound1 = { SinOsc.ar(\freq.kr(220)) * 0.2 };
    ~mysound2 = { SinOsc.ar(\freq.kr(440)) * 0.2 };
    ~mysound3 = { SinOsc.ar(\freq.kr(880)) * 0.2 };
    ~mysound4 = { SinOsc.ar(\freq.kr(1760)) * 0.2 };
    MIDIFunc.cc({arg ...args; ~mysound1.set(\freq, args[0]*10);}, 66, 0);
    MIDIFunc.cc({arg ...args; ~mysound2.set(\freq, args[0]*10);}, 77, 0);
    MIDIFunc.cc({arg ...args; ~mysound3.set(\freq, args[0]*10);}, 88, 0);
    MIDIFunc.cc({arg ...args; ~mysound4.set(\freq, args[0]*10);}, 99, 0);
)

Wav2Sketch

For playing wav file from memory, there is AudioPlayMemory class from teensy audio library.

More infos: https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html

compile the converter

MacOS and *nix users need to compile the sample conversion software "wav2sketch" from command line.

The C source can be downloaded here: https://raw.githubusercontent.com/PaulStoffregen/Audio/master/extras/wav2sketch/wav2sketch.c

Next to the wav2sketch.c source file, a "makefile" must be present to compile the program.

Copy&paste the makefile below to a file called "makefile" without file extension. Open a terminal in the directory, where "wav2sketch.c" and "makefile" is present and type "make". If no errors occured you should now have the program "wav2sketch" in the same directory.

convert wav files

WAV-Audio samples can just be placed in the same directory as the program for conversion. In the Terminal, if it points to the folder of your "wav2sketch" program already, type ./wav2sketch to execute the program. Otherwise you can just type the absolute path, for example "/Users/yourUserName/Desktop/Wavs/wav2sketch". This should generate cpp/h files for all wav files present in the folder.

As an option, uncompressed 16 bit samples can be generated by passing the option "-16" to the program. MacOS users need to install XCode environment, linux useres need gcc (should be installed anyway).

Makefile (for Mac OS/*nix users)

CC = gcc

CFLAGS = -O -Wall

all: wav2sketch

.c.o:
	$(CC) $(CFLAGS) -c $<

wav2sketch: wav2sketch.o
	$(CC) -o wav2sketch wav2sketch.o

clean:
	rm -f *.o