Audio abspielen in Cpp

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
RoboShowcase
Beiträge: 2
Registriert: 16 Aug 2019, 08:11

Audio abspielen in Cpp

Beitrag von RoboShowcase » 16 Aug 2019, 08:28

Hallo

habe mir über das offizielle Fischertechnik-Repo die TXT C-Download Beispielprojekte angesehen.


https://github.com/fischertechnik/txt_demo_c_download

Soweit funktionieren die Programme auch (Motoransteuerung). Ein Problem habe ich nun aber beim Abspielen von Audiodateien (Standard 01-Airplane Datei). Beim Ausführen des unten aufgeführten Code-Beispiels wird zunächst die Zeile

Code: Alles auswählen

"**PlaySound Action:1, Nr:1 Rep:1 Cmd: 1"
PlaySound: Sound Start
auf die Konsole geschrieben, dann erhalte ich jedoch einen Segmentation Fault.

Code: Alles auswählen

#include <stdio.h>          // for printf()
#include <unistd.h>         // for sleep()
#include <iostream>

#include "KeLibTxtDl.h"     // TXT Lib
#include "FtShmem.h"        // TXT Transfer Area

// Common debugging stuff for RoboProLib
unsigned int DebugFlags;
FILE *DebugFile;
FISH_X1_TRANSFER    *pTArea;

int main(void) 
{
	if (StartTxtDownloadProg() == KELIB_ERROR_NONE)
	{
		pTArea = GetKeLibTransferAreaMainAddress();
		if (pTArea)
		{


				pTArea->sTxtOutputs.u16SoundIndex = 1;
				pTArea->sTxtOutputs.u16SoundRepeat = 1;
				pTArea->sTxtOutputs.u16SoundCmdId++;

		}
		StopTxtDownloadProg();
	}
	return 0;
}
Habe bereits verschiedene Indizes ausprobiert. Leider ohne Erfolg. Habe aktuell Firmware 4.4.4.0. Der Onlinemodus über die ROBO Pro-Umgebung funktioniert.

Hat das schon jemand hinbekommen oder kennt vielleicht eine bessere Doku als die Readme im Git?
Danke für jeden Hinweis.

RoboShowcase
Beiträge: 2
Registriert: 16 Aug 2019, 08:11

Re: Audio abspielen in Cpp

Beitrag von RoboShowcase » 19 Aug 2019, 10:09

Ok thanks for the answer. The StopTxtDownloadProg remains from the example.

The sleep methods serve as the duration the engine is running till I change the signal. Besides I used them to test some functionality. For exmaple what if the programm sleeps after the audio method is called (to keep the main method alive).

At the moment I switched to the community firmware to use python, with wich the audio file is playing.

Torsten
Beiträge: 310
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)

Re: Audio abspielen in Cpp

Beitrag von Torsten » 20 Aug 2019, 15:48

RoboShowcase hat geschrieben:At the moment I switched to the community firmware to use python, with wich the audio file is playing.
You don't neccessarily need to switch to the community firmware to use python on the TXT.
Python can also be used with the original fischertechnik firmware in online- as well as in offline-mode.

Best,
Torsten

Antworten