Arduino Forum

Using Arduino => Audio => Topic started by: Pat-The-Pirate on Feb 17, 2017, 08:58 pm

Title: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 17, 2017, 08:58 pm
Hi All,

Tonights search brought up:

http://littlebits.cc/projects/get-your-bach-on-with-the-arduino-midi-organ

http://sandsoftwaresound.net/source/arduino-project-source/combo-organ/midivox-organ-comboorgan-ino/

both by Paul Drongowski.

I get compile errors even though the compile SEEMS to have found all the library files called up on my PC.

Code: [Select]
In file included from E:\My Documents\Arduino\MidiOrgan\MidiOrgan.ino:110:0:

Farf.h:25: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_C3[] = {

 ^

Farf.h:70: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_Db3[] = {

 ^

Farf.h:112: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_D3[] = {

 ^

Farf.h:152: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_Eb3[] = {

 ^

Farf.h:190: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_E3[] = {

 ^

Farf.h:226: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_F3[] = {

 ^

Farf.h:260: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_Gb3[] = {

 ^

Farf.h:292: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_G3[] = {

 ^

Farf.h:323: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_Ab3[] = {

 ^

Farf.h:352: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_A3[] = {

 ^

Farf.h:379: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_Bb3[] = {

 ^

Farf.h:405: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Farf_B3[] = {

 ^

In file included from E:\My Documents\Arduino\MidiOrgan\MidiOrgan.ino:112:0:

Vox.h:24: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_C3[] = {

 ^

Vox.h:68: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_Db3[] = {

 ^

Vox.h:110: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_D3[] = {

 ^

Vox.h:150: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_Eb3[] = {

 ^

Vox.h:188: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_E3[] = {

 ^

Vox.h:224: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_F3[] = {

 ^

Vox.h:258: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_Gb3[] = {

 ^

Vox.h:290: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_G3[] = {

 ^

Vox.h:321: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_Ab3[] = {

 ^

Vox.h:350: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_A3[] = {

 ^

Vox.h:377: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_Bb3[] = {

 ^

Vox.h:403: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM Vox_B3[] = {

 ^

In file included from E:\My Documents\Arduino\MidiOrgan\MidiOrgan.ino:114:0:

Tables.h:27: error: 'prog_uchar' does not name a type

 prog_uchar PROGMEM MidiNotes[] = {

 ^

Tables.h:71: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM FarfNumOfSamples[] = {

 ^

Tables.h:87: error: 'prog_int16_t' does not name a type

 PROGMEM const prog_int16_t* FarfWaves[] = {

               ^

Tables.h:106: error: 'prog_int16_t' does not name a type

 prog_int16_t PROGMEM VoxNumOfSamples[] = {

 ^

Tables.h:122: error: 'prog_int16_t' does not name a type

 PROGMEM const prog_int16_t* VoxWaves[] = {

               ^

MidiOrgan:288: error: expected unqualified-id before 'if'

   if (genNote[I]) { \

   ^

MidiOrgan:318: error: expected declaration before end of line

 #pragma GCC optimize ("-O2")

                             ^

Multiple libraries were found for "MIDI.h"
 Used: E:\My Documents\Arduino\libraries\MIDI
 Not used: C:\Program Files\Arduino\libraries\Midi
exit status 1
'prog_int16_t' does not name a type


I'm obviously missing something here but do not have the wisdom, intuition or ability in C++ programming to understand what is not happening.

Neither website offers much in after-sales service. Mind you, I didn't have to pay, either.

Can anyone help?

Cheers!

Jim

PS I will collect all the libraries and attach them if necessary; I'm hoping that someone will point out the obvious which is currently not mine to discern.
Title: Re: Arduino organ project - compile fail
Post by: jaholmes on Feb 17, 2017, 09:47 pm
Old code, methinks.  Those 'prog_' types are all deprecated.  You should be able to replace 'prog_int16_t' with 'const int16_t' and be good to go.  Use of the 'prog_' type was redundant here to begin with, since PROGMEM was also given.
Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 17, 2017, 09:53 pm
Or use an older IDE.
The sandandsoftware one compiles on Arduino IDE V1.0.5 r2.

Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 18, 2017, 04:08 pm
And I posted the above without actually testing it or thinking properly about what I will need to do in the near future.

Took jaholmes advice and changed all prog_inst to const_inst but its still failing to compile in IDE 1.6.13 with a problem in Tables.h, same error.

PROGMEM const const_int16_t* VoxWaves[] = {

Anyone got it to compile and test it yet?
Title: Re: Arduino organ project - compile fail
Post by: jaholmes on Feb 18, 2017, 08:09 pm
Is there such a thing as const_int16_t?  I was suggesting 'const int16_t' (with a space).
Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 18, 2017, 08:50 pm
Thank you, that helped a lot, but now:

PROGMEM const int16_t* FarfWaves[] = {


variable 'FarfWaves' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

Your help has been great so far.
Title: Re: Arduino organ project - compile fail
Post by: jaholmes on Feb 18, 2017, 09:02 pm
Hmmm.  That seems like that should work.  Maybe PROGMEM needs to go after const?  I usually stick it after everything else (after the []), but the docs make it seem non-picky.
Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 18, 2017, 09:18 pm
No, that fails.
Any other thoughts or ideas?

Thanks again.
Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 18, 2017, 09:34 pm
const int16_t* const FarfWaves[] PROGMEM = {

seems to compile OK.
Title: Re: Arduino organ project - compile fail
Post by: jaholmes on Feb 18, 2017, 10:21 pm
Ah!  I'd missed the * in this one. I was still seeing the original issue.  What you've got there looks like goodness.  Glad it works now!
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 19, 2017, 11:42 pm
Hi folks,

Back at the ranch again. Thanks for all the interest & suggestions.

Looking at the comments about "old" software, the website:

http://littlebits.cc/projects/get-your-bach-on-with-the-arduino-midi-organ#comment_11171

says it published the sketch on Feb 13th 2017, and someone called f.j2 commented that the code was great. (I've asked him how he did it). (I'll let the question go for a few hours; the guy might live in Hawaii, or Auckland NZ).

I'll try the suggestion "const int16_t* const FarfWaves[] PROGMEM = {" in the morning (I'm a bit knackered tonight!).

Thanks again all

Jim
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 20, 2017, 10:13 am
const int16_t* const FarfWaves[] PROGMEM = {

seems to compile OK.
This has got embarassing.

If I don't reply, you will all (correctly) think I am a rude and ungrateful person. So I have to reply with whatever state I find myself in.

Trouble is, I don't know which code has to be replaced by Sparx's suggestion, or even which file! which is worse.

I found plenty of instances of "const int16_t* const FarfWaves[] PROGMEM = " in Tables.h.

I tried a suggestion in Littlebits that the code was written for a Leonardo, but changing the board in the IDE did not help.

Given that folk said they were already using the code as-is sucessfully, I think I'll try the suggestion of an older IDE version for the moment.

We are talking about a Genuino Dummio here, you know. Next I'll be bleating about not being able to find an older IDE.

Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 20, 2017, 10:55 am
So, replaced Midi library (again) with 4.2 to be sure (I hope) that I used the "right" one -  no joy, still various compile errors.

Sparx, when you say "const int16_t* const FarfWaves[] PROGMEM = {

seems to compile OK."

are you saying it does compile (and work)?

I seem to be going around in circles!

I think it might be best to wait until he replies to my help request on

http://littlebits.cc/projects/get-your-bach-on-with-the-arduino-midi-organ#comment_11171

(if ever).

Thanks for all the interest & comments

Cheers

Jim
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 20, 2017, 09:49 pm
Well, I think I've got to the bottom of the problem.

On http://littlebits.cc/projects/get-your-bach-on-with-the-arduino-midi-organ
the guy admits

(a) His blog Arduino sketch no longer compiles after some considerable period. Nothing in the blog to warn the unwary.

(b) He now says it is coded for the Leonardo, despite the fact the the word "UNO" is splashed all over the sketch. ("Leonardo" turns up as a footnote in a comment about 80 lines fown the code).

(c) He says "I tried compiling the code with the board "littleBits w6 Arduino Module (Leonardo)" and got an error in the build process itself, i.e., the tool chain has a bug. I've had problems like this with UNO, too. Board definitions don't always seem to be in sync with the tool chain."

To me, this has all the hallmarks of a disastrously unstable environment. As I've said elsewhere, Atmel ought to take the situation by the scruff of the neck if they want to avoid adverse reaction. It's a fantastic product, but so frustrating when sketches fail to compile, even when the post is only 2 weeks old!!! I am beginning to wonder if I should go back to Zilog . . . .

Having had a good moan, is there any chance that the code could be re-written for an UNO? I see Sparx having some success but don't know what edits he did. The chance of having 5 notes playable is very tantalising!

Title: Re: Arduino organ project - compile fail
Post by: sparx266 on Feb 21, 2017, 12:45 pm
I think there may be some progress.

I have attached a revised Healer program.
Healer uses a different MIDI library than the fortyseven effects one, so this has been attached too.

Remove any other library called MIDI and put this one in the libraries folder.  Restart the IDE and it should pick it up. Load the sketch in and hit compile as per normal.

Jim or anyone want to give this a go in a later IDE and post back?

Jim, have sent you a PM.

Regards.
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 21, 2017, 01:32 pm
Hi Sparx,

I did as you suggested, and while I got more errors (mostly relating to "unused parameter" I DID get a white text

Sketch uses 10380 bytes (32%) of program storage space. Maximum is 32256 bytes.
Global variables use 642 bytes (31%) of dynamic memory, leaving 1406 bytes for local variables. Maximum is 2048 bytes.

at the end.

However, when I tried "Upload" I got

Invalid library found in C:\Program Files\Arduino\libraries\Midi: C:\Program Files\Arduino\libraries\Midi
Invalid library found in C:\Program Files\Arduino\libraries\Midi: C:\Program Files\Arduino\libraries\Midi

and I don't get any audio.

I tried the ComboOrgan with 1.0.5, 1.0.6 and 1.8.3 with no great success.

I suspect

(a) That these sketches require a Midi controller with controls that the sketch can interpret as a drawbar, and that you can't expect any sound until this happens,

(b) That I've got the wrong libraries, and

(c) That I am actually trying to get things to work that I am not competent to understand.

I really appreciate the help that everybody has offered, but I kind of feel that I am beginning to waste everyone's time; it is not simple to resurrect code that the authors wrote a relatively long time ago, and no longer have an interest in. If they would only reply it would have been great.

For an Arduino dummy like myself, it is probably impossible to get these sketches working, especially as you need either a shield, or a scope to check whether the SCK is toggling. I think I'll have to stick to one-note-at-a-time until I can master enough "C" to go polyphonic.

In addition, I've only got a 1MB connection here which makes surfing a nightmare.

I'll attach the error file in case anyone wants a look. Sorry to be so negative!

Cheers

Jim
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 21, 2017, 07:35 pm
Hi All,

I just saw Sparx's mention that "Healer uses a different Midi library than the FortySeven effects one" and my heart sank.

I had a feeling this might be the case, because other sketches I have that use "Midi.h" , were working until I changed to the 47 library. Then they threw up (errors).

Isn't this a bit daft?

I don't have enough understanding to write these sophisticated audio sketches, but I do know daft when I see it.

I couldn't have different versions of libraries side-by-side on my PC with the SAME FILE NAME - I'd get lost! And you can't have more than one, otherwise the compiler gets cross.

As I said before I think I'll have to go and learn Arduino and C++ and write polyphonic organ sketches that don't require a Midi library.

Time for a nice glass of Merlot, I suspect.

Who needs libraries anyway?

Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 21, 2017, 11:08 pm
Thanks to Sparx for all the effort. I have a horrible feeling that I've picked up something horrible like the "wrong" Midi.h file, or perhaps there's something in this PC which hates libraries.

I have all the Arduino source files and libraries on my C: drive, and all the sketches on a separate hard drive, which I've heard is a fairly normal way to arrange the Arduino world.

Otherwise, I am in the lap of the gods, and it is not a good place to be. I've got all the upper- and lower-case issues out of the way, and there is no spitting back about missing any of the libraries.

Is there an official Midi library that comes with the IDE? I only ask, because the errors, in my head, seem to point to this library as being the weakest link, and I seemed to get directed to a gihub repository for it; who knows what sort of mashing it has had in there?

Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 22, 2017, 12:41 pm
Well, full marks to Sparx ( ! ) for getting me in possession of a working copy of the Littlebits  / Drongowski MidiOrgan. I can now play 5 notes at a time i.e. a full chord on the piano, which is just magic.

I don't know precisely how he achieved it, that's perhaps a story for another day. The Midi library definitely had a hand in it, assuming libraries have hands.

For me it calls the so-called Arduino Libraries into question, because it seems from the Github site that there is more than one "Midi" library, and the one the works is labelled "Development" which to my mind says that it could be changed.

Wouldn't it be better for the sales of Arduino products to control the libraries so that they don't become backwards-incompatible?

Perhaps I'd better retract that question.

But it does seem that other midi-dependent sketches such as Roto and Healer all suffer from the same blight, although I can't prove it. Grumpy Mike wouldn't put up with it!!

If anyone wants, I'll poke out the working file set & attach it in this thread.

What a happy ending to a months futile poking!
Title: Re: Arduino organ project - compile fail
Post by: Pat-The-Pirate on Feb 22, 2017, 02:57 pm
I had a look at Roto, which is now toggling my three SPI pins quite nicely. Heck, I'm getting good.

(My shield uses pin 10 for SPI SS per the Atmel datasheet & I altered the SPI PortB instructions to suit:

(were      PORTB &= ~(1<<1);  PORTB |= (1<<1);
now    PORTB &= ~(1<<2);  PORTB |= (1<<2);  )

Still no audio . . .
Title: Re: Arduino organ project - no sound during stress testing
Post by: Pat-The-Pirate on Feb 24, 2017, 03:47 pm
Well, full marks to Sparx ( ! ) for getting me in possession of a working copy of the Littlebits  / Drongowski MidiOrgan. I can now play 5 notes at a time i.e. a full chord on the piano, which is just magic.
The organ kept stalling so I started grubbling around looking for possible causes.

Well, I found that the code reads A0 but the project doesn't add any hardware to actually set A0. A0 is floating if you follow the project instructions. Not good practice.

If A0 is at zero volts, a Farfisa organ sound is selected. In theory, if you raise A0 above 2.5V, you get a Vox sound. However, there is no sound at A0 >= 2.5V because of some other perhaps code- or UNO-related problem. (The project is geared toward Leonardo).

This caused endless grief for me although I didn't realise it at the time: my unconnected A0 tended to fly above 2.5V when powering up the board, in addition to any static effects, so half the time I wasn't getting any sound, but not for reasons connected with the libraries etc.

Fixed in minutes with a 1K resistor and a SPST switch to 3.3V.

The other thing he doesn't say in the description is that it can only play 5 octaves, which is Ok once you know what's happening, but leads to paranioa if everything else has gone wrong in the meantime.

 >:(