# SelectInput() fails

**URL:** <https://discourse.processing.org/t/selectinput-fails/38735>\
**Category:** Libraries\
**Created:** [September 13, 2022, 1:13pm UTC](https://discourse.processing.org/t/selectinput-fails/38735 "2022-09-13T13:13:54Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![blippr](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@blippr](https://discourse.processing.org/u/blippr)\
**Post date:** [September 13, 2022, 1:13pm UTC](https://discourse.processing.org/t/selectinput-fails/38735/1 "2022-09-13T13:13:54Z")

</div>

Hi,

I get this error message in the console:

> The method selectInput(String, String) in the type PApplet is not applicable for the arguments (String)

when trying to run this script:

```auto
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import ddf.minim.*;

int SAMPLES = 30000;

Minim minim;
AudioSample sample;

void setup()
{
  size(512, 200);
  
  String file = selectInput("Select audio file to encode.");

  if (file == null) {
    exit();
    return;
  }
  
  try {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  
    minim = new Minim(this);
    sample = minim.loadSample(file);
    
    float[] samples = sample.getChannel(BufferedAudio.LEFT);
    float maxval = 0;
  
    for (int i = 0; i < samples.length; i++) {
      if (abs(samples[i]) > maxval) maxval = samples[i];
    }
    
    int start;
    
    for (start = 0; start < samples.length; start++) {
      if (abs(samples[start]) / maxval > 0.01) break;
    }
  
    String result = "";  
    for (int i = start; i < samples.length && i - start < SAMPLES; i++) {
      result += constrain(int(map(samples[i], -maxval, maxval, 0, 256)), 0, 255) + ", ";
    }
  
    clipboard.setContents(new StringSelection(result), null);
    
    JOptionPane.showMessageDialog(null, "Audio data copied to the clipboard.", "Success!", JOptionPane.INFORMATION_MESSAGE);
  } catch (Exception e) {
    JOptionPane.showMessageDialog(null, "Maybe you didn't pick a valid audio file?\n" + e, "Error!", JOptionPane.ERROR_MESSAGE);
  }
  
  exit();
}

void stop()
{
  sample.close();
  minim.stop();
  super.stop();
}

```

I am following this guide:

> **[Simple Arduino audio samples](http://highlowtech.org/?p=1963)**
>
> This tutorial explains how to do simple playback of short (~4 second), low-bitrate (8 KHz) audio samples from Arduino using only a speaker.

and there is a link to a Processing application but I can not run it, probably since I am on OSX Monterey. The source code above is taken from here:

> **[GitHub - damellis/EncodeAudio: Processing sketch for translating audio files...](https://github.com/damellis/EncodeAudio)**
>
> Processing sketch for translating audio files into numeric values. - GitHub - damellis/EncodeAudio: Processing sketch for translating audio files into numeric values.

However, I can not get the scrip to work, as described above.

Can I please get some help on this?

Cheers

---

_[View the full topic](https://discourse.processing.org/t/selectinput-fails/38735)._
