Stories

Opening A PDF in Ionic on Android

Posted on Updated on

Well, after nearly a week of trial and error of trying out other people’s tutorials and having no luck, and getting very frustrated…  I’d like to present my findings of what has worked for me.

Please understand, this example will NOT work straight out of the box. You’ll need to modify your code. I post these things, so I don’t forget how I did it, but hopefully so you can learn and use them too. The post is subject to change and be updated.

Oh, and this image too. It’s me…

DbzLJyiU8AIosGS

I finally found the last piece to my solution here.

Firstly, this will probably (I’m guessing) on of the most important things in the future to know, as the Ionic framework, Cordova, PhoneGap, NodeJS is changing so rapidly, it could not work tomorrow. So, here are the important values of version numbers for you.

$ ionic info

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils : 1.19.2
 ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.9
 Cordova Platforms : android 6.4.0 ios 4.5.4
 Ionic Framework : ionic-angular 3.9.2

System:

Node : v8.11.1
 npm : 5.6.0 
 OS : macOS High Sierra

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

newspaper.ts

import { Component, NgZone } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import {Http} from '@angular/http';
import { GlobalsService } from '../../globals/globals'; 
import 'rxjs/add/operator/map';
import { File } from '@ionic-native/file';
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer';
import { DocumentViewer } from '@ionic-native/document-viewer';
import { FileOpener } from '@ionic-native/file-opener';

@Component({
 selector: 'page-newspaper',
 templateUrl: 'newspaper.html',
})
export class NewspaperPage {

constructor(public navCtrl: NavController, public navParams: NavParams,
 private http: Http,
 public globalsvals: GlobalsService,
 private file: File,
 private transfer: FileTransfer,
 private platform: Platform,
 private document: DocumentViewer,
 private fileOpener: FileOpener
 ) {
 }
 
 posts: any;

 url: string = '/newspaper/json.php';
 myAssociativeArr: any = []; 
 items1: any = [];
 
ionViewDidLoad()
 {
 console.log('ionViewDidLoad NewspaperPage');
 console.log(this.globalsvals.newspaperpdf_json); 
 
 if (this.globalsvals.release == true)
 {
 this.url = this.globalsvals.newspaperpdf_json;
 } 
 
 this.http.get( this.url )
 .map(res => res.json())
 .subscribe(data => { 
 this.items1 = data; 
 //console.log (this.items); 

 // With this, I can now get each record as it loops through them
 
 for (const item of this.items1.items)
 {
 console.log (item.url); 
 var newElement={}; 
 newElement["url"] = item.url;
 newElement["filename"] = item.filename;
 this.myAssociativeArr.push(newElement);
 }
 }); 
 }
 
itemTapped(event, item) 
{
 console.log("Item Tapped"); 
 let path = null;
 
 if (this.platform.is('ios')) {
 path = this.file.documentsDirectory;
 } else if (this.platform.is('android')) {
 path = this.file.dataDirectory;
 } 
 
 const transfer: FileTransferObject = this.transfer.create();
 console.log(item.url);
 const url = item.url;
 transfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
 console.log('download complete: ' + entry.toURL());

 this.fileOpener.open( this.file.dataDirectory + 'file.pdf', 'application/pdf')
 .then(() => console.log('File is opened'))
 .catch(e => console.log('Error opening file', e)); 
 
 }, (error) => {
 // handle error
 }); 
 
 }
}

newspaper.html

<ion-header>
  <ion-navbar> 
    <ion-title><img alt="logo" height="40"  src="./assets/images/logo.png" ></ion-title>
  </ion-navbar>
</ion-header>


<ion-content padding>  
  <h2>Newspapers</h2>
      
<ion-list>          
   <ion-item ion-item *ngFor="let item of myAssociativeArr" >
    <ion-item ion-item *ngFor="let item of myAssociativeArr" >
     <ion-row>
      <ion-col col-2>
       <button icon-only (click)="itemTapped($event, item);" style="background-color: white !important;"> 
         <img [src]="item.thumb">
        </button>
       </ion-col>
       <ion-col col-10>
         <h1 (click)="itemTapped($event, item);" [innerHTML]="item.title_date">
         </h1>
       </ion-col>
      </ion-row> 
    </ion-item>
  </ion-list>
</ion-content>

My JSON feed file for PDFs can be found here: (which you’ll need to configure)
https://github.com/vrdriver/JSONpdffeed

You'll probably also need to add the cordova plugins for the following:

import { File } from '@ionic-native/file'; 
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer'; 
import { DocumentViewer } from '@ionic-native/document-viewer'; 
import { FileOpener } from '@ionic-native/file-opener';

Add them to your app.module.ts file like that, and also as a provider, in that same file.

 File,
 FileTransfer,
 DocumentViewer,
 FileOpener

You may notice I have a globals.ts file as well. It’s just my way of keeping track of global variables.

import { Injectable } from '@angular/core';

@Injectable()
export class GlobalsService
{
    // If this is for a release, set this to true, so that all of the values will
    // not use proxie values.  
    // SET THIS TO TRUE IF YOU ARE DEPLOYING
    public release:boolean = true;  
    public newspaperpdf_json:string = 'https://resources.site.com/apps/pdf/newspaper/json.php';    
}

The other thing with my code, is you’ll also notice that I’m using a few proxies as well. This is the reason for the “release” variable. If it’s a deployed (finalised) app, then I’ll set this value to true, and it’ll change all the code to pull in the correct URLs – as well as a few other minor non-dev things.

Some sites claimed to have these lines work. They did not.

this.document.viewDocument(url, 'application/pdf', {});
window.open(encodeURI(path + 'c4i.pdf'), '_system');

Still, other well respected sites, claimed files would work, that when their example loaded, it pointed the user to download a file from the Android Play Store to open the PDF file… ???

These to me, were not options. Some claimed to work with open the file is a webkit browser window… Why would you do it that way anyway? I have a native PDF viewer, let’s use it.

I hope this document is as clear as mud. I’ll be doing more tests, and probably updating it as I discover more things. But, as it stands, it worked… so far. 🙂

Advertisements

Zetta vs StationPlaylist

Posted on Updated on

Firstly, both radio playout systems are good. They just have a different set of features, and strengths and weaknesses.

 

Things Zetta has over SPL:

  • Ability to script the loading of audio
  • Multi-User customisation and granular permissions
  • Real-time manipulation of the playout log over network from any Zetta computer
  • A truly networked system
  • Completely database driven system
  • Multiple redundancy points
  • Connectivity with multiple Zetta sites/offices.
  • Cross Platform IVT – through web browser with Zetta2Go
  • Visual Segue Editor for the log
  • Visual Cue audio editing on files
  • Can run multiple stations from the same database
  • A non-fixed location database
  • Built-in Audio Editor
  • Multipoint audio ducking for segues
  • World wide team of 24/7 support
  • Better on-air sound
  • Better integration of the Library of songs, links and ads in the system as a whole

 

When integrated with GSelector as the scheduler:

  • Granular hourly depart restrictions
  • Unscheduling and scheduling of specific categories
  • Complicated Artist separation
  • Programming can be scheduled from any computer with GSelector on it
  • Multiple schedules for different stations
  • Can easily see when the station is scheduled, and what is missing from the log – very helpful when programs are delayed from suppliers.
  • Can schedule music and programming separately, or Ids, or links etc.

 

Advantages of SPL over Zetta

  • Smaller program size
  • Cheaper to purchase and on-going maintenance
  • Buy out licence
  • Less resources required to run it
  • DSP Plugin effects built in for audio sound
  • Streaming Module is included
  • One small database
  • Simple Audio Metadata/playlist history is stored in files
  • Lower minimum hardware requirements
  • Less computers required to run it
  • Can run on Linux or Mac (through Wine)
  • Easy to find audio, based on it’s Windows File system architecture.
  • Scheduling of programs can be potentially quicker, (but can easily be broken if a reschedule is required)

These are just the things I can think of, but I know there are plenty more differences, and similarities.

Both systems share many things in common, of which many are standard, such as Live assist, Automation, GPIO etc.

I made a comparison a few years ago here:
https://stephenmonro.wordpress.com/2015/11/13/radio-broadcast-software-compared/

If you really want to know how good Zetta is, and see it fly from a guy who uses it daily at a commercial station, this video is a must see. The things on this video that are done, can not be done in SPL on the fly like this.
https://www.facebook.com/TimLeeOZ/videos/217605938795418/

Radio station discovery for ARM processors

Posted on

Some thoughts. These are ideas to play audio on a linux based platform, on a low powered device.

This is a daemon console audio player. It can play playlists

http://moc.daper.net/
https://github.com/jonsafari/mocp

How do you get the playlists generated so that it continues perpetually?

 

 

This can generate it’s own radio station based on scripting

liquidsoap.info/
https://github.com/savonet/liquidsoap

 

The Raspberry Pi devices need to have an RTC, otherwise they don’t know what time, or date they are each time they are turned on, unless they are connected to the internet.

This device solves that. http://www.uugear.com/product/wittypi2/

 

 

 

I saw this on a forum post. UK Sky News Audio feed: (I don’t know if it’s current)

StationPlaylist pushing to different ShoutCast 2 Streams.

Posted on Updated on

Well, it’s only taken much of the day, however it’s something that I finally got working, and it’s usually when you thought you’ve exhausted all options that you give up… but I had to try that one last time… And… I got it!

StationPlaylist is a great little piece of software for radio broadcasting. One of the things it has built in, is a web streamer, so that you can push the audio to a a ShoutCast or IceCast Stream.

This features work wonderfully and very simply if you only have one station. But, when you need to scale, things become less obvious – a lot less obvious.

In preparation for getting a multi-SPL install working and emulated on a VPS, or powerful VMs, I had to try this out just using the demo versions, and after much carry on, it seems to be working.

So, the idea is to get (at least) 2 versions of SPL to push to a linux ShoutCast 2 server. You can find multiple install instructions on how to do that, so I won’t even try to explain that part. I’ve written about it a couple of times in the past.
ShoutCast on a VPS
Shouter. Server

The problems with ShoutCast (apart from the fact that Winamp (NullSoft) or ShoutCast are doing a terrible job with their latest rendition of server software for the DYIer), and with SPL is that getting them to marry up with multiple instances is a real pain.

The secret to getting SPL to go to the correct server, with the correct SteamID is in the “Encoder Password” box.

Entering the following will connect you as User 3, a password of testing1, to stream Id 3.

3:testing1:#3

Screenshot 2018-04-02 22.13.32-edit

That’s not the only thing to configure. After putting bits together over the course of the last several hours and finding a couple of key pieces of information, it’s all come together.

It took me a long time to see this, but it’s mentioned in the SPL documentation under the Studio Help, Operation, Internet Streaming: under the heading “SPL Encoder Configuration”.

Note: SPL Encoder supports sending a single stream to a Shoutcast v1 or v2 server.  However, from Shoutcast Server v2.4.7, multiple streams may be sent to the same server by placing the stream ID in the Password field using this syntax…
password:#n   where n is the stream ID number.  eg. MyPass:#2

The other significant discovery was getting a configuration file working correctly too.

This is the sc_server_basic.conf file I ended up using for my testing:

 

; NOTE: for any relative paths specified are relative to
; sc_serv and not to where the conf file is being stored

; here we will setup where the log and other related files
; will be stored. make sure that these folders exist else
; sc_serv will throw an error and will close itself down.
; we will make the logs save to the sc_serv2 directory
logfile=logs/sc_serv.log
w3clog=logs/sc_w3c.log
banfile=control/sc_serv.ban
ripfile=control/sc_serv.rip

; for testing we will make the server only work locally
; (i.e. localhost / 127.0.0.1) though if this is left out
; or set to publicserver=always then we attempt to make a
; connection to the YP for listing - do not forget to add
; in a 'streamauthhash' value for any public streams made
;publicserver=never

; if you're wanting to use a different port to use for any
; connections then you can use this option e.g. to use 80
; otherwise port 8000 is used as the default to listen on.
;portbase=80

; password used by sc_trans or the Winamp dsp plug-in
; NOTE: remember to change this to something else
password=testing

; password used for accessing the administation pages
; NOTE: remember to change this to something else
adminpassword=changeme

; now we will specify the details of the stream we're going
; to serve which can be done as follows
;streamid=1
;streampath=/test.aac

; or

; it can be done like this which is how it needs to be done
; if you are going to provide multiple streams from sc_serv

password_1=testing1
streamid_1=1
streampath_1=/test1.mp3

password_2=testing2
streamid_2=2
streampath_2=/test2.mp3 
streampassword_2=testing1

password_3=testing
streamid_3=3
streampath_3=/test3.mp3 
streamadminpassword_3=testing 
streampassword_3=testing1

The significant things are the multi-stream configurations.

Screenshot 2018-04-02 22.46.51

In this image, there are only 3 separate streams shown as connected to my local server. 2 are using a demo copy of SPL, and the third (stream 2) is using the Shoucast DSP plugin in Winamp on a Windows 10 box (of which that plugin doesn’t work in SPL. If it did, I wouldn’t have spent all day figuring this out).

Screenshot 2018-04-02 22.17.51

That’s pretty much it. I hope it helps you, running multiple streams on the same server, through StationPlaylist, emulated in Wine using multiple instances with the help of PlayOnLinux.

The sky is the limit!

 

Troubles with sharing files on Windows 10

Posted on

It’s a bold statement, but after getting very frustrated last night, I thought I’d share a few revelations, and the troubles I had in sharing some files.

Recently, I spun up a couple of LinuxMint VMs. These typically have worked well, but there are areas where I’ve struggled, and at this point, I’m sharing about file sharing – from a Windows 10 box.

Here is the scenario. I want to share a folder that is inside the C:\Program Files (x86).

To be exact, it’s this one. I want to share this:

C:\Program Files (x86)\StationPlaylist\Playlist\

It works fine in MacOSX as a shared drive, but, when it comes to Linux, it’s a whole different ball game, and it just doesn’t want to play ball.

I have plenty of other shared folders on that Windows10 computer, and they all work fine. But, a folder buried in the “Program Files”, just doesn’t want to play ball.

I went through many versions of Samba config files, authentication methods, username/passwords, domain, problems with updates, SMB versions and a whole bunch of things. I even had to create a username and password in Windows, because LinuxMint didn’t want to just do an anonymous user login.

… in the end I gave up, extremely frustrated. Why does it have to be so difficult?? It works fine on the Macs… but not Linux.

I tried on last thing thing and made a fresh share on the Windows box, put it in “C:\Playlist” and shared it, and the share worked immediately.

Windows10 is a pain as it is, but throwing in Linux to the mix as well… it quickly turns to a nightmare.

Here is the connection procedure… The attempt to connecting to the share is from the “Program Files” share. That fails brilliantly. The second share, “C:\Playlist”, works spectacularly.

Screenshot 2018-04-02 15.28.22Screenshot 2018-04-02 15.28.46Screenshot 2018-04-02 15.28.59Screenshot 2018-04-02 15.29.23Screenshot 2018-04-02 15.29.30Screenshot 2018-04-02 15.29.39Screenshot 2018-04-02 15.29.46

Go figure… :/

 

VNC on Linux Mint – 3 steps!

Posted on Updated on

I’ve seen so many explanations of getting VNC to work well on Linux straight out of the box.

Well, they are all basically a pain to get working, with about 10 steps. It shouldn’t be so hard – especially when using Mint!

So, I was chuffed to find this guide which explains it very well! – in 3 steps! 😀

 

I hate ripping content like this, but in an effort to keep it available in case the site disappears, here it is:

 

https://helpdeskgeek.com/linux-tips/easiest-way-remotely-connect-linux-mint-os/

The Easiest Way to Remotely Connect to Linux Mint from Any OS

I have Linux Mint installed on a test machine at home that I use for playing around with Linux in general, but I use a Windows 10 machine as my main daily driver. I wanted a convenient way to connect to my Linux Mint machine from Windows or Mac without having to install all kind of packages, etc.

If you browse the Internet, you’ll see articles about installing XRDP, x11VNC, etc, etc. This all sounded a bit too complicated for me, especially since Linux Mint has built-in desktop sharing capabilities.

Warning: It’s worth noting that the method I’m describing below disables encryption for the remote connection.

For me, this is a non-issue since I am simply connecting to the Linux box from within my local network. If you need to have encryption enabled for the remote connection, I’ll be writing up another post soon on how to do that as it’s a bit more complicated.

Configure Desktop Sharing Settings

In Linux Mint, click on the menu button, Preferences and then Desktop Sharing. This will open the Desktop Sharing Preferences screen where you can enable other users to connect to the Linux system.

Under Sharing, go ahead and check the Allow other users to view your desktop and Allow other users to control your desktop boxes. Under Security, it’s probably a good idea to uncheck the You must confirm each access to this machine as that would require you to locally confirm the remote connection before it is accepted. If you’re giving someone else access to your machine, then it’s probably worth checking so that you can control when someone connects to your machine.

In order to prevent anyone from connecting to your machine, check the Require the user to enter this password box and type in a decently strong password. Click Close as we are done with this dialog.

Install dconf Editor

Next, we have to disable the encryption that is currently required by Vino, which is the package installed in Linux Mint by default. We have to install the dconf Editor, so that we can change the default settings.

Open Terminal and type in the following command:

sudo apt-get install dconf-editor

Once the package has been installed, click on the Linux Mint menu, then All Applications and scroll down till you see dconf Editor.

Open the editor and then navigate to orggnomedesktop remote-access.

In the right-hand pane, go ahead and uncheck the require-encryption box. Close the editor and then restart your Linux box. Once you are logged back in, we can try to connect.

Connect Using VNC Client

At this point, you can download your favorite VNC client for Windows and connect to the Linux box. In my case, I used the VNC Viewer program from RealVNC. You don’t have to sign up or pay for anything to use the viewer.

Type in the IP address for your Linux box and press Enter. Since there is no encryption, you’ll get a popup dialog telling you that your connection is not secure. Once you get past that message, you’ll have to enter the password you typed when we first setup desktop sharing settings on Linux Mint.

Hopefully, if all went well, you should now see the desktop for your Linux Mint machine.

As previously mentioned, this is a quick fix way to get into your Linux machine, but it is not secure. This means that all the data sent over the network is completely unencrypted, including passwords, etc. So, make sure no one can snoop on you if you plan to use this method. I’ll be posting another article soon on how to connect remotely to your Linux Mint box using encryption. If you have any questions, post a comment. Enjoy!

Raspberry Pi 3B FM Broadcasting… It can be done, but I want more.

Posted on Updated on

This is a discovery document and ramblings…  I’ve added to it all day and processed thoughts. I may adjust it and fix it, but, this is as it stands, as it took me about a day to compile.

 

 

This is going to be an interesting.

 

 

End Game:

Host a radio station on the Pi that just works. You turn it on and it starts transmitting a program.

In doing this…

Multiple ways:

Route Any audio that comes from the Pi to be transmitted via the FM TX.

Or

Read an M3u file and feed that to a audio player that pipes to the FM TX.

 

Hopefully to be able to use StationPlaylist Creator and Studio.

 

So far, only 1 version of a transmitter has succeeded.

Worked:

 

Only Plays WAVE files

https://www.youtube.com/watch?v=NdjQw6P0HLA
sudo ./fm_transmitter -f 91.3 -r star_wars.wav
https://github.com/somu1795/fm_transmitter

 

 

 

 

 

Failed:

 

http://www.instructables.com/id/Raspberry-Pi-PiFMPlay-Simplified-FM-Transmitter/

https://github.com/ChristopheJacquet/PiFmRds

https://github.com/Mikael-Jakhelln/PiFMPlay

 

Maybe this could work:

 

Haven’t Tried:

https://blog.morrolinux.it/raspberry-pi-fm-radio-transmitter-stereo-a2dp-bluetooth-rds/

 

 

https://github.com/somu1795/fm_transmitter

Broadcast from a usb microphone (see arecord manual page for config)

arecord -d0 -c2 -f S16_LE -r 22050 -twav -D copy | sudo ./fm_transmitter -f 103.3 -

Where it redirects a device to the FM TX…

Maybe I could set up a device/ALSA or something, and pipe that in to the TX?

 

 

Very Helpful, but didn’t work.
https://howtoraspberrypi.com/create-radio-transmitter-raspberry-pi/

 

 

Someone else wants the same thing:

Is there a way to redirect all audio to the FM transmitter? #18

 

The different Pins. We need GPIO 4, which is PIN 7

https://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29

 

 

Other information:

http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter

 

Mostly idiots talking about “breaking the law”. At under 100mw, which this isn’t even close, it’s perfectly legal. But, it does contain some good RF stuff.

Easily Turn Your Raspberry Pi into an FM Transmitter

 

This is a kernel module for playback… Not sure on the status or if it works though.

 

https://github.com/spencerwhyte/RPIKMFMAD/issues/1

 

https://github.com/ChristopheJacquet/PiFmRds/issues/44

 

 

 

 

 

I think this is the key:

https://github.com/ChristopheJacquet/PiFmRds/issues/44

The easiest way to basicly play anything you want to, is by using audio loopdevices.
Simply load snd-aloop via modprobe (or just add it to /etc/modules), and you are ready to go.
use a terminal to start PiFm:
sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 - | sudo ./pi_fm_rds -audio -

then you are free to play whatever you want with whatever program you want, as long as it allows you to specify the audio device you want to use to output to.
for example:
sudo aplay -D hw:Loopback,0,0 "FILE"

if you want to, you can even define the loopdevice as your standard output device, by changing the .asoundrc in your home directory to
# .asoundrc pcm.!default { type plug slave.pcm "hw:Loopback,0,0" }

That way you can even use VLC within X to transmit your audio.

 

 

https://unix.stackexchange.com/questions/310164/create-virtual-device-in-asoundrc-file

 

 

Trying:

This generates a new loopback device which wasn’t there before

sudo modprobe snd-aloop

Maybe Stationplaylist can actually play a file through this method… Not that it can see the loop-back audio driver?

 

sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 - | sudo ./pi_fm_rds -audio -

 

Trying: https://github.com/F5OEO/PiFmRds

This is the latest version of the PiFmRds in Github.

Run this as well, Otherwise the build will fail when compiling it.

 

sudo apt-get install libsndfile1-dev

 

wget https://github.com/F5OEO/PiFmRds/archive/master.zip
unzip master.zip
cd PiFmRds-master/
cd src
make

Fails to build.

 

This builds:

git clone https://github.com/ChristopheJacquet/PiFmRds.git
cd PiFmRds/src
make clean
make

This will broadcast something on 107.5

sudo ./pi_fm_rds

This Demo will play a file in slow motion ( or correctly without the loopback I think)

sudo ./pi_fm_rds -audio sound.wav

 

Shows the Audio Devices.

arecord -L

 

This transmits, but it locks up the device after about 2 seconds.

sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 - | sudo ./pi_fm_rds -audio -

https://linux.die.net/man/1/arecord

 

 

pi@raspberrypi:~/fm_transmitter-WAVE_Only $ sudo ./fm_transmitter -f 107.9 star_wars.wav

 

sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 – | sudo ./fm_transmitter -f 107.9 -audio –

 

 

 

THIS WORKS!

Get the sourcecode from here:

https://github.com/markondej/fm_transmitter

 

 

sudo apt-get install make gcc g++
make

 

cd fm_transmitter-WAVE_Only/

sudo modprobe snd-aloop

sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 – | sudo ./fm_transmitter -f 107.9 -audio –

 

Even at 22.5k it still stutters. A little less, but still noticeable.

sudo arecord -fS16_LE -r 22500 -D hw:Loopback,1,0 -c 2 – | sudo ./fm_transmitter -f 107.9 -audio –

 

 

pi@raspberrypi:~/fm_transmitter-WAVE_Only $ sudo modprobe snd-aloop
pi@raspberrypi:~/fm_transmitter-WAVE_Only $ sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 – | sudo ./fm_transmitter -f 107.9 -audio –
Playing: STDIN
Recording WAVE ‘-‘ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Right Click on the Speaker icon at the top. Set the Audio to LoopBack

Raspbian VLC should work with some Audio files and push play.

It should work!

 

CPU Stays at about 30%+

Audio also stutters slightly

 

install WineTricks and  Q4Wine

 

 

 

Currently I can’t get SPL to output to the Loopback – even though it says it is.

The WineCFG test outputs to the correct location, just not SSL.

 

Trying to set it up so it’s automatic a little.

Create the following files with a +777 permission and you should be good. Just change the location of the fm_transmitter file.

 

 start_radio.sh

sudo modprobe snd-aloop
#sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 - | sudo /home/pi/fm_transmitter-WAVE_Only/fm_transmitter -f 107.9 -audio -
sudo arecord -Dhw:Loopback,1,0 -fS16_LE -r44100 -v -c 2 - | sudo /home/pi/fm_transmitter-WAVE_Only/fm_transmitter -f 107.9 -audio -

 

stop_radio.sh

sudo kill -9 $(pidof arecord)
sudo pkill -9 -f arecord
sudo kill -9 $(pidof fm_transmitter)
sudo killall -9 fm_transmitter
sudo pkill -9 -f fm_transmitter

 

 

Current conclusion: 20180317

I can now stream from any native program that is happy to follow the audio output rules of the system. VLC works fine, as does XMMS.

However, both programs have mild stutters about once a second for about .001 of a second. It’s minor, but it is noticeable. It’s like a CD with a minor glitch skip. Frustrating.

This isn’t there when “sudo ./fm_transmitter -f 91.3 -r star_wars.wav” is called. So, there is a buffering/hangup issue when using arecord to pipe the audio through, of which I need to investigate further and see if there are optimisations that can be made.

This current set up also using a consistent 30% of CPU resources in the X windows setup of the Noob version of the pi OS.

I suspect the problem could relate to the fact that it’s MP3s being upsampled to a WAVE @ 44.1khz stereo, captured, and then pushed out to the FM TX program. That’s a lot of data for a small processor.

 

 

 

Another possible option?

I could use the web streamer in SPL and capture that and feed it to the arecord. More investigation required, but I do recall someone mentioning that somewhere.

http://www.martinjhiggins.co.uk/shoutcast-streaming-from-a-raspberry-pi/

I’m trying IceCast2

 

sudo aptitude install icecast2

I wonder if I could use this as a template…

sox -t mp3 http://www.linuxvoice.com/episodes/lv_s02e01.mp3 -t wav -  | sudo ./pi_fm_rds -audio -

 

My Current Idea? – which could just put extra strain or processing on the device… but, it could do the opposite…?

Set SPL Output as NULL.

Set up the Streaming to the location newly created IceCast2 host.

So, go from SPL -> Icecast2 URL.

sox -t mp3 http://localhost/stream.mp3 -t wav - | sudo /home/pi/fm_transmitter-WAVE_Only/fm_transmitter -f 107.9 -audio -

 

After setting this up and SPL correctly connecting to the IceCast2 server, this doesn’t work because of the following error:

Playing: STDIN
sox WARN wav: Length in output .wav header will be wrong since can’t seek to fix it

 

It plays for about 3 seconds and then fades.

 

 

Next Stop… Asking the ExaGear guys. They are supporting wine, or similar. Time to see if they can assist…

 

Either that, or find a new player that read the m3u or pls files and have StationPlaylist Creator generate new files via CLI on a schedule.

The audio player/FM service could be stopped and started on a regular hourly basis so it keeps a rough time?

 

After letting it run overnight, I came to find that the radio broadcasting had stopped. This is probably because arecord has a time limit on it… Could be wrong.

Also, I’m thinking that the slight delay in the broadcast could be related to the speed of the card I’m using: Just a thought.

https://www.dwidigitalcameras.com.au/lexar-300x-32gb-45mb-s-high-performance-micro-sd-memory-card-with-sd-adapter.html

 

 

 

Observations and other research

ExaGear needed to have winbind install to run the demo version of StationPlaylist Creator

My result:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
 600000

 

https://github.com/yeokm1/pi-radio

https://linux.die.net/man/1/arecord

https://alsa.opensrc.org/Jack_and_Loopback_device_as_Alsa-to-Jack_bridge#id02

XMMS2 – “Winamp”:
https://bytemyvdu.wordpress.com/2015/11/19/raspberry-pi-winamp/

https://makezine.com/projects/raspberry-pirate-radio/

After an original night trial without any audio radio tests to see how the pi could handle it, SPL Locked up overnight for some reason. Probably because it is a demo version.

When the fridge compressor pump kicked in to keep the fridge cooler, it must have caused a surge/brownout, as the pi rebooted, and the digital radio turned itself on… all the defaults.